statement block where the variable declaration is located. For example, run the following code: {int A = 10; A = 2;} Char C;} in this Code, variable A ranges from row 3 to row 5, the range of variable C is from row 6 to row 7.
3.6.5 scope of constantThe range of a constant is exactly the same as that of a variable.
3.6.6 SummaryThis article describes variables and constants. The following is a complete code that can be compiled and run in JDK or ecli
Java tutorial translation Sequence Java Introduction Build a JSE development environment-install JDK and eclipse Language basics Java Hello World Program Analysis Variable Java Variables Java Native type Conversion of Java
Java language Base composition1. KeywordsRefers to some of the words, these words are given a special meaning of Java, it is no longer called the word.For example:class demo{ publicstaticvoid main (string[] args) { System.out.println ("Hello world!" ); }}The class, public, static, void are keywords in
Definitions and features of keywords
In fact, this is one of the important differences between C + + and Java. The C + + compiler does not initialize local variables, so it is easy to forget to initialize a variable in C + +, in which case the value of the variable is exactly the current random value in the memory area. This is obviously where the program is prone to error.Like Java, classes in C + + can have data fields and static variables.
Java basic Syntax (i)---keywords, constants, variables, operatorsFirst, the key wordDefinition: A word that is given special meaning by Java.Features: The expression is English lowercase.1. Keywords for defining data typesBasic data type:Integer type: Byte (1 bytes, maximum value 127) Short (2 bytes, maximum 2^15-1)Int (4 bytes, Max 2^31-1) long (8 bytes, maximum 2^63-1)Floating-point type: float (single-
Problem and a solution
Today, the company's JAVA project encountered a problem: when the xls file is generated, if there is a large amount of data, ArrayIndexOutOfBoundsException may occur.Google found a BUG in the jxl package used in the item (open-source library used to handle xls files.We also found a solution: Success. After a try, this method is indeed feasible.Another solution-Reflection
However, I was reminded by my predecessors that I could gi
constants: Constants with values unchanged.
Grammar:
Data type constant name = value;
Double PI = 3.14;
Note:
The general default constant name is uppercase.
Relationship between variables and constants (quantity relationship)
Let's start with a simple example to understand the relationship between variables and const
In Java there are constantpool constant pools, constant pools of constants for classes, methods, interfaces, and references to objects that hold string constants that typically hold symbolic links to symbols or real strings.Let's take a look at a simple code and decompile bytecodepublic class Test {public static void m
point to the same object.2. data in the stack is not synchronized with data destruction in the heap. Once the method ends, the local variables in the stack are destroyed immediately, but the objects in the heap are not necessarily destroyed. Because there may be other variables that point to this object, it is destroyed only if there are no variables in the stack that point to the object in the heap, and it is not destroyed immediately, and can be destroyed when the garbage collection is scanne
, you can use the isJavaIdentifierStart and isJavaIdentifierPart methods in the Character class to check.
Java reserved words cannot be used in variable names.
4) multiple variables can be declared in one statement. Different variables are separated by commas.
2. Variable assignment and initialization:
The value of a variable can be obtained in two ways. One is a value assignment. To assign a value to a var
C ++ and variables and constants in Java
In fact, this is an important difference between C ++ and Java. The C ++ compiler does not perform initialization checks on local variables, so it is easy to forget to initialize a variable in C ++. In this case, variable value the variable occupies the memory area and there is a random value currently. This is obviously a
Keywords in Java:Some words in the Java language that have special uses are called keywords. The keyword on the Java compiler has a special meaning, in the application of the program must be cautious Oh!! Common keywords in Java:Q: So many, can't remember Ah ... -_-||A: Now you do not need to remember all, mix a familiar, in the course of learning, you will gradually find the feeling and remember themYes, a
http://www.verejava.com/?id=16992564786810The constants in the /*java are divided into the following 1. Integer constant 2. Floating-point constant 3. character constant 4. Boolean constant 5. String constant */public class finalvariable{public static void main (S Tring[] args) {//constant: Variable//1 cannot be changed. Integer constant final int up=0;
In Java, every variable, constant is a type.variables :Example: int i;Double A;1 The variable name must be a sequence of alphanumeric characters beginning with a letter. But unlike most programming languages, the range of letters and numbers in Java is larger, and the letters include ' a ' ~ ' Z ', ' a ' ~ ' Z ', ' _ ' or any Unicode character that represents a letter in any language, such as Chinese: decla
ConstantA constant is an identifier whose value remains unchanged during running. Constants can only be referenced in the program, but cannot be assigned a value again.Constant naming rules:1. In JAVA, add the final keyword to the variable declaration to represent the constant, and add the static keyword to represent the class variable. In general, we combine sta
A pool of string constants in Java
There are two forms of string object creation in Java, one in literal form, such as string str = "Droid", and the other is the method of using the standard constructed object of new, such as string str = new String ("Droid "), both of which we often use in code writing, especially in literal ways. However, there are some differ
are literal constants that are stored in a constant pool,The string object referenced by S2 is also a literal constant, and the constant "Zhanghanqing" appears in the constant pool, so Java does not open up new memory for the object referenced by S2, but instead allows S2 to refer directly to the previously existing "Zhanghanqing"In-Memory impersonation:So S1==s2 is true;S3 is created with new, and the mem
One, the identifiers in Java must follow the following rules:1. Cannot start with a number2. Cannot use keywords3, in the custom Java identifier should be aware that Java is strictly case-sensitive , in order to improve the readability, to use meaningful identifiers as far as possibleSecond, the name specification in Java
1. Key words1.1. Words that are given meaning by the Java language (e.g. class,interface,public, static)1.2. All lowercase1.3. Precautions (Goto and const are reserved as key words)2. Identifiers2.1, to the class, interface, method, the character of the name of the variable2.2. Composition rules (A: English case, B: Data, c:$ _)2.3. Precautions (cannot start with
The so-called constant, which we can understand as a special variable , whose value is set, is not allowed to change during program operation. Using Constants in your program can improve the maintainability of your code .The constant value of Java is represented by a string, and the extents are divided into different data types:1, integral type constant, such as 1232, the real type constant, such as 3.143,
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.