#HashMap# 2022-01-26 22:58:18 阅读数:254
1.1.1 java Programming language is a strongly typed language , Of course, there are weakly typed languages , such as JavaScript
Strongly typed definition language : Language to enforce data type definitions . in other words , Once a variable is assigned a data type , If not forced , Then it will always be this data type . for instance : If you define an integer variable a, Then it's impossible for the program to a Treat as string type . Strongly typed definition language is a type safe language
Weak type definition language : Languages in which data types can be ignored . It's the opposite of a strongly typed definition language , A variable can assign values of different data types .
TIPS: 1b=1 position
1B( byte )=8 position
1KB( One thousand bytes )=1024B
i) integer
ii) floating-point
iii) Character
about char Characters need to be noted that , Often use escape characters , Such as \t tabs ,、\n Indicates a newline character, etc
It uses \t Shi Shiyi 8 Multiple complement of , for example :
char ch = '\t';
System.out.println("abcdefghabcdefgh");
System.out.println(ch+"abcdefghabcdefgh");// The front is empty 8 position
System.out.println("abcdefg"+ch+"habcdefgh");// because "abcdefg" Yes 7 position , A filling 1 position
iiii)boolean type
Common conversion problems
(1)
float num =3.14;//3.14 stay java Default is double
System.out.println(num);// Display error
The reason for the error report is because java The middle decimal is... By default double type , If float The accuracy will be lost ( Later, we will talk about the specific reasons )
(2)
Test01
int num = 10;
byte n = (byte)num;// Cast is used here to byte Sure
Test02
int num = 128;
byte n = (byte)num;// The result is -128, The reason is beyond byte Table number range (-128-127), Here you can see the original code, inverse code and complement code
(3) The relationship between big data types and small data types ( a key )
example :
Test01
int num = 10;
float f = 'A'+num+12+3.14F+12.12;// The data type obtained here depends on the large type , Obviously double
Test02
char ch = 'A'+num// Go to int Type dependence
copyright:author[#HashMap#],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/01/202201262258152961.html