当前位置:网站首页>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 .
边栏推荐
- Investment analysis and future production and marketing demand forecast report of China's paper industry Ⓥ 2022 ~ 2028
- Summary of small program performance optimization practice
- El Table Radio select and hide the select all box
- pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
- System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
- 百度研发三面惨遭滑铁卢:面试官一套组合拳让我当场懵逼
- 2022-2028 global elastic strain sensor industry research and trend analysis report
- What are the advantages of automation?
- Global and Chinese market of air fryer 2022-2028: Research Report on technology, participants, trends, market size and share
- 智能网关助力提高工业数据采集和利用
猜你喜欢
Regular expression (I)
Latex download installation record
2022-2028 global small batch batch batch furnace industry research and trend analysis report
2022-2028 global tensile strain sensor industry research and trend analysis report
C语言指针面试题——第二弹
Normal vector point cloud rotation
Hands on deep learning (35) -- text preprocessing (NLP)
Svg image quoted from CodeChina
C language pointer classic interview question - the first bullet
QTreeView+自定义Model实现示例
随机推荐
Modules golang
Golang defer
Fabric of kubernetes CNI plug-in
Machine learning -- neural network (IV): BP neural network
C语言指针经典面试题——第一弹
Svg image quoted from CodeChina
Hands on deep learning (35) -- text preprocessing (NLP)
In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
El Table Radio select and hide the select all box
ASP. Net to access directory files outside the project website
C language pointer interview question - the second bullet
Trees and graphs (traversal)
Matlab tips (25) competitive neural network and SOM neural network
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
C # use smtpclient The sendasync method fails to send mail, and always returns canceled
Lauchpad X | 模式
Deadlock in channel
Are there any principal guaranteed financial products in 2022?
Global and Chinese markets for laser assisted liposuction (LAL) devices 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