Pick up the Java first article, a reviewJavatheData types, constants, variables~
-
Java data types (8 types of 4 types)
-
Basic data types
- numeric
- plastic
- Byte (1 byte, 8 bits)
- Short (2 bytes, 16 bits)
- Int (4 bytes, 32 bits)
- Long (8 bytes, 64 bits)
- floating-point
- Float (single-precision floating point, 4 bytes, 32 bits)
- Double (high precision float, 8 bytes, 64 bits)
- plastic
- character
- Char (2 bytes, 16 bits)
- The Boolean
- Boolean (1 byte 8 bits, true or false)
- numeric
-
Reference data type
- String (String, immutable)
//byte byte byteNumber = 10086; //short short shortNumber = 10010; Int intNumber = 2000; //int intNumber = 2000; // String is the default value of a numeric type, so you need to add a suffix L to the end of the String to indicate that it is a long integer. It is also possible to write a lowercase L, but L is like 1. L long longNumber = 999999L; //float// Since the default float type is double, we need to transition down tofloat, you need to add the suffix Ffloat floatNumber = 3.14 f; //double double doubleNumber = 3.1415926; //char can contain only one character, enclosed in single quotation marks char c ='我'; Boolean Boolean, representing true or false Boolean b =true;
boolean b = false; //String String STR ="Hee hee";
Copy the code
- Constants, variables, static variables
Final int VALUE = 1; final int VALUE = 1; final int VALUE = 1; final String MY_TAG ="my_tag"; Java is a strongly typed language and must specify the type when declaring a variablefloatX = 1.1 f; // A static variable is a class variable that does not need to be instantiated. Wally static String tag = wally static String tag = wally static String tag = wally static String tag ="barry"; // Assign tag = to class A"wally"; Wally system.out.println (tag); // Wally system.out.println (tag); Public static final String BASE_URL = public static final String BASE_URL = public static final String BASE_URL ="http://www.baidu.com";
Copy the code