Java day07

Data type-char

             char-----可以表示更大的正整数,因为char没有负数
            成员变量没有手动赋值,系统自动默认值

The default values ​​of the eight data types: default values
byte, short, int, long 0
float, double 0.0
Boolean false
char \u0000
The default values ​​of the eight data types are all aligned with 0

A Chinese occupies 2 bytes
public class TestByte01{ public static void main(String[] args){ char ='a'; System.out.println(a); } }




Escape character

转义字符的种类型在以前的记录里由
println中ln 具有换行的功能(在输出中)

Escape character:
//newline character
\n
//tab character
\t
//backslash
\
Explanation: the first backslash has escape function
//single quotation mark character
'
//double quotation mark character
"
Since JDK With native2ascii.exe command, you can convert text into unicode encoding form

           怎么使用native2ascii.exe命令?
                  在命令窗口中输入native2ascii,回车,然后输入的文字之后回车即可得到unicode编码
                         如:
                               char = '\u4e2d'  //中  对应的unicode编码是  4e2d;

Plastic surgery

           Java语言当中的”整数型字面值“被默认当做int类型来处理。要让这个”整数型“被当作long类型处理的话	需要在”整 数                      型字面值	“后面添  l/L,

          自动类型转换机制:
                                         小容量可以自动转换成大容量,称为自动类型转换机制
                                         如: 
                                                long x = 456;
                                                long整形类型,456在没有赋值之前是整形值,在赋值给x之后就是长整型变量
                                                在占用内存空间上,从占用4字节变化到8个字节,这种机制叫做自动类型转换机制
                                                char \u0000   \u0000代表空
                                           
                                           大容量不能直接转换成小容量
                                           大容量转换成小容量,需要进行强制转换
                                           强制类型转换需要加”强制类型转换符“,
                                           加上强制类型转换,在运行阶段可能会损失精度,所以需谨慎使用
                                           
                                           强转原理:
                                                             原始数据:8个字节
                                                             转换后的数据      :变成4个字节

The computer's stored data is stored in the form of complement

byte

byte b = 50;
// 50 is a literal value of type int, and b is a variable of type byte. Obviously, a large-capacity int is converted to a small-capacity byte, and a coercion symbol is required, but it has passed the
analysis:
because byte b = 50 It is useless to exceed the value range of byte.
When an integer denomination does not exceed the value range of byte, the literal value can be directly assigned to a variable of type
byte. The value range of byte: [-128~127]
forced conversion Symbol: byte b1 = 128;
byte b1 = (byte) 128; //-128 [compilation result]
Note:
Class name, interface name: capitalize the first letter, capitalize the first letter of each word,
method name, variable name: The first letter is lowercase, and the first letter of each word after it is capitalized.
Constant name: each word is capitalized

Guess you like

Origin blog.csdn.net/weixin_53515338/article/details/115143010