This paper re-learn the details about the missing records before the foundation of the Java school.
1. java belong to a strongly typed language
2.8 kinds of basic data types: byte, short, int, long, float, double, char, boolean, as automatic data type conversion:
byte, char, short ---> int ---> long ---> float ---> double, to note that:
- boolean data type not automatically converted.
- When operation between byte, char, short int result type.
1 class ByteTest{ 2 public static void main(String[] args){ 3 byte a = 3; 4 byte b = 4; 5 byte c = a + b; 6 System.out.println(c); 7 8 } 9 }
-
When direct byte b = 3 + 4; correct result is output.
- Depending on storage, float is greater than double the capacity.
- After long type to add "l" or "L", if not, then will default to the int type, int when out of range of error.
- float and long similar.
3. Since the increase does not change the original data types
public static void main (String [] args) { Short S =. 3 ; S + =. 1; // do not change the data type // S = S + 2; // not compile by System.out.println (S); }
Expression 4. switch structures, only six data types: byte, short, char, int, enumerated types, String type. After the case can only declare a constant, you can not be declared range.