Java programming: attaches methods to enumeration constants in enumeration enum
Package enumeration; // append the method to the enumerated constant public class UnitsConverter {private static double numberToConvert = 0; public static void main (String [] args) {// TODO Auto-generated method stub if (args. length = 0) {System. out. println ("Usage:
and definitions are not distinguished.As for the scope of the variable is the effective range, out of this range, the variable can not be used, which is specific to the following code to illustrate.Give a little chestnut to understand the use of variables.int length = ten=; System.out.println (length);This will output 10 and 20 in turn.In addition to variables, Java also has a guy called constants, with th
In program execution, the amount whose value cannot be changed is called a constant, and the amount whose value can be changed is called a variable.One, variable1. The variable name must be a valid identifier2. Variable names cannot be duplicated3. You should choose a meaningful word to make a variable nameSecond, constantConstants are also commonly referred to as "final variables", and constants can be assigned only once throughout the program and ar
This seems to be an unknown language skill. I see people writing java. Initializing static constants are all
Copy Code code as follows:
public static final map
Static{
Data.put ("A", "a");
blah blah blah}
Use the static block of the class to initialize data, but there is another way to do it:
Copy Code code as follows:
public static fi
Java Introduction to data types and variables and constantsFirst, Java Data Type
The Java language is a strongly typed language that defines specific data types for each data and allocates different sizes of memory space in memory.
Note: integer default: int decimal default: DoubleDefines the integer type long, which needs to be followed by a number
1 , JavaScript ConceptJavaScript is a scripting language; After writing, you can run it directly (the process of compiling is missing)2. JavaScript ComponentECMAScript: The standard of language (definition grammar) since the introduction of ES6 in 2015; A new version will be introduced every year in the futureDom-document object Model (Document object models)Bom-browser Object Model3. Basic grammar* Case Sensitive Eg:atguigu, Atguigu and Atguigu-for three content* Code of the normativeHTML: The
Constants and pointersVariables that can be modified after a declaration are declared as constants if they cannot be modified in order to protect the variable, using the const modifier.In C + +, a pointer variable is assigned a 4-byte (32-bit) block of memory to store the address pointing to the data, so the pointer type involves two concepts, the pointer itself (a 4-byte memory block), and a pointer to the
2.4.1 ConstantsConstants represent values that cannot be changed.Categories of Constants in Java:1, integer constant. All integers2, decimal constant. All decimals3, Boolean constant. More specific, there are only two values. True false.4, character constant. A numeric letter or symbol is identified by a single-quote (' ').5, string constant. Identifies one or more characters with a double-cited number.The
1. Variable:
Definition: believe that the definition of it should not be said, we should have been familiar with the familiar.
For example:
A,a1,name and so on are all valid variables.
Description
1 Java requires that the type of the variable be declared before using a variable.
2 the declaration of a variable in Java is a complete Java statement, so you sh
When we define constants, we can define constants in the interface, such as:
package org.zy.demo.base; public interface InterfaceDemo { final String name="this is my name"; }
The above are the interfaces and constants that I define.
The definition of a constant does not indicate a public static
I implement this interface:
package org.zy.demo.base; public
address.Constant modifier finalAre some of the differences when declaring constants and variables, each value assigned to a variable opens a new memory address. Each constant corresponds to only one memory address, and multiple identical constant memory addresses have only one.Iii. type Conversion1), Automatic type conversionAutomatic type conversion is equal to conversion, or small to large conversion of a class2), forced type conversionForcing type
.4. If one of the operands is of type double, the result of the calculation is a double type.Long y=12345678987654321l; The end plus L indicates that he is a long type, and if not added, it cannot be compiled.Float x=1.7f//Eight data types only long and float plus suffixes.Variables in Java are either one of eight basic types or a reference to an object, and we only have two choices.The reference does not contain the actual data of the object he refer
To tell the truth, before writing C # really did not pay attention to naming norms, today read an article, summed up the following several naming methods:Class or interface: A word: The first letter of a word must be capitalized : Student multiple words: The first letter of each word must be capitalized as an example: Studentinfo method or variable: A word: all lowercase as: Main Word: Starting with the second letter, capitalize each initial letter
1. The oldest// not processed Public Static Final int process_status_untreated = 0; // has been received Public Static Final int process_status_accpected = 1; // has been processed Public Static Final int process_status_processed = 2;2, improved version of the Public Static Final classprocess_status{//not processed Public Static Final intuntreated = 0; //has been received Public Static Final intaccpected = 1; //has been processed Public Static Final intProcessed = 2;}3
The so-called constant, which we can understand to be a special variable, its value is set after thechanges are not allowed during program operation. Syntax:final constant name = value;Using Constants in your program can improve the maintainability of your code. For example, in project development, we need to specify the user's gender, at this time can be defined as a constant sex, assigned to "male", in the need to specify a user-specific place to ca
Declaring variables individually can increase the readability of your program.
Many programmers like to add a or V before a declared variable, plus C before a constant, plus a type shorthand for it, which is a good habit to support.
Example: String vstrname;
It is best to initialize a variable declaration.
The declaration of a constant is final, with the customary constant name capitalized. The declaration cannot be changed, and if you want to declare a constant that is used in more than one
anonymous classes without the class keyword?1) to have the new operator, similar to the normal class instantiation of an expression.2) to implement an interface or inherit a class, the example above is to implement the HelloWorld interface.3) class body (body), where you can define fields, methods, or even partial cla
Java internal class (InnerClass) ---- non-static internal class, static internal class, local internal class, anonymous internal classMany people are not familiar with the java underwear Class
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service