Basic data types of java knowledge points

Basic data types of java knowledge points

1. Integer type
① Memory (1 byte = 8 bits) Range
byte 1 byte -128~127
short 2 byte -32768~32767
int 4 byte
long 8 byte
② To declare long type variables, you must use 'l' or 'L' ending

long l1=12345678910L
③通常,定义整型变量时,使用int型

2. Floating point type (representing a value with a decimal point)
① Memory
float 4 bytes
double 8 bytes
The range of values ​​represented by float is larger than long
③ When defining a float type variable, the variable must be 'f' or 'L' end

3. Character type: char (1 character = 2 bytes)
① To define a char type variable, usually use a pair of '', only one character can be written inside, and it cannot be empty
② Expression method: declare a character or escape character

char c='\n';
System.out.print("hello"+c);
System.out.println("world");
③char类型是可以进行运算的,因为它都对应有Unicode码
//直接使用Unicode码来表示字符常量
char c='\u000a'//表示\n
④定义String型,通常使用一对“”,内部可为空

4. Boolean type: boolean
① can only take one of two values: true, false

Supongo que te gusta

Origin blog.csdn.net/m0_50760467/article/details/110410131
Recomendado
Clasificación