当前位置:网站首页>2. Data type
2. Data type
2022-07-04 09:47:00 【skeet follower】
Catalog
1.3 Double precision floating point variables
1.4 Single precision floating point variables
1.1 Integer variables
Grammar format :
int Variable name = Initial value ;
int num = 5;// Define an integer variable
System.out.println(num);
Be careful :
7.int stay JAVA Four bytes in , The value range is -2^31———2^31-1.
lnteger yes int The wrapper class , Let's look at java The value range of integer data in
notes :‘+' The usage here is , Examples are as follows ;
1.2 Long integer variables
Grammar format :
long Variable name = Initial value ;
Code example :
long num = 10;// Define a long integer variable , Initial value writing 10l It's fine too ( Lowercase L, Not numbers 1).
System.out.println(num);
long stay JAVA Middle occupancy 8 Bytes ,Long Is its package name , Next, let's look at the value range of long integers
reflection : Excuse me, String[] args What does this parameter do ? Runtime command line arguments !!!
1.3 Double precision floating point variables
Grammar format :
double Variable name = Initial value
Code example :
double num = 1.0;
System.out.println(num);
Code 1 :
int n = 1;
int m = 2;
System.out.println(n/m);
The execution result is 0; Because of java in int Divide int The value of is still int( The fractional part is discarded );
If you want 0.5; be :
double a = 1.0;
double b = 2.0;
System.out.println(a / b);
// Execution results
0.5
Code 2 :
double num = 1.1;
System.out.println(num * num)
// Execution results
1.2100000000000002
double stay JAVA Middle occupancy 8 Bytes ,Double Is its package name , Now let's check the value range

1.4 Single precision floating point variables
Grammar format :
float Variable name = Initial value ;
Code example :
float num = 1.0f; // writing 1.0F It's fine too
System.out.println(num);
1.5 Character type variable
Grammar format :
char Variable name = Initial value ;
Code example :
char ch = "A";
Be careful :

1.6 Byte type variables
Grammar format :
byte Variable name = Initial value ;
Code example :
byte value = 0;
System.out.println(value);
1.7 Short integer variables
Grammar format :
short Variable name = Initial value ;
Code example :
short value = 0;
System.out.println(value);
1.8 Boolean type variable
Grammar format :
boolean Variable name = Initial value ;
boolean value = true;
System.out.println(value);
Number of bytes | 1 | 2 | 2 | 4 | 8 | 4 | 8 | There's no rule |
data type | byte | char | short | int | long | float | double | boolean |
Packaging | Byte | Character | Short | lnteger | Long | Float | Double | Boolean |
1.9 String type variables
Grammar format :
String Variable name = " Initial value ";
String name = "zhangsan";
System.out.println(name);
Be careful :

You can also splice strings and integers :
The above code description , When one + When there is a string in an expression , Is to perform string splicing behavior .
边栏推荐
- 2022-2028 global special starch industry research and trend analysis report
- On Multus CNI
- Golang Modules
- C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
- Write a jison parser from scratch (6/10): parse, not define syntax
- 2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
- MySQL develops small mall management system
- C语言指针面试题——第二弹
- 2022-2028 global protein confectionery industry research and trend analysis report
- Lauchpad x | MODE
猜你喜欢
Mmclassification annotation file generation
C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
How can people not love the amazing design of XXL job
Intelligent gateway helps improve industrial data acquisition and utilization
法向量点云旋转
IIS configure FTP website
MATLAB小技巧(25)竞争神经网络与SOM神经网络
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
How web pages interact with applets
Leetcode (Sword finger offer) - 35 Replication of complex linked list
随机推荐
Mmclassification annotation file generation
Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
Golang type comparison
Write a mobile date selector component by yourself
mmclassification 标注文件生成
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
Hands on deep learning (34) -- sequence model
PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers
How web pages interact with applets
Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
Are there any principal guaranteed financial products in 2022?
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
el-table单选并隐藏全选框
Qtreeview+ custom model implementation example
How do microservices aggregate API documents? This wave of show~
Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
Implementing expired localstorage cache with lazy deletion and scheduled deletion
Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of bipolar generators 2022-2028: Research Report on technology, participants, trends, market size and share