Identifier
Common naming conventions (see known names)
Package name All lowercase
Class or interface, one word: Capitalize the first letter, multiple words: Capitalize the first letter of each word.
method or variable: One word: first letter lowercase, multiple words: Starting with the second word, capitalize each word first.
constants: All uppercase. One word: uppercase. Multiple words: Uppercase and separated by _. ??
Variable
Operation, it is not holding the space to operate, the real use of the value in this space. This space is named for the variable name.
Even if the variable has a data type and variable name, if there is no value, it is a garbage space, meaningless.
The scope of a variable is valid within the same curly brace. A variable with the same name cannot be in the same scope.
Original code, anti-code, complement
? In the computer, there are 3 notation numbers: The original code, the inverse code and the complement. All data is performed in the complement.
? ? The original code:? is the binary fixed-point notation, that is, the highest bit is the sign bit, "0" means positive, "1" is negative, and the remaining bits represent the size of the value.
? Anti-code: the inverse of a positive number is the same as its original code; the inverse of a negative number is a bitwise negation of its original code, except for the sign bit.
? Complement: The complement of a positive number is the same as its original code, and the complement of a negative number is the minus 1 of its inverse code.
Data type:
Java is a strong language, and each kind of data requires a well-defined data type.
Integer default int type, decimal default double type.
Type conversion Considerations:
1, from small to large automatic conversion
2, from large to small conversion possible loss of precision?
byte a = 3; int b = 4; System.out.println (a+b); // 7 int C = a +b; System.out.println (c); // 7 byte d = a +b; System.out.println (c); // error, loss accuracy byte E= (byte) (A +B); System.out.println (c); // 7
? ? 3, the addition of variables, will take into account the type conversion, the first type conversion and then calculate, and the results of the calculation after the assignment, perhaps consider the type conversion.
? ? Constants are added, the results are evaluated first, and then the type is considered to be within the value range of the due type
byte b1=3,b2=4=b1+b2; // accuracy missing b = 3+4; // 7
Character calculation?
? ? The string is added to the other data types, which is the connection, the result or the string
// a // 98 // helloa1 // 98hello
Java Learning Note 3, variables, data types