当前位置:网站首页>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.5Code 2 :
double num = 1.1;
System.out.println(num * num)
// Execution results
1.2100000000000002double 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 gasket metal plate heat exchanger industry research and trend analysis report
- El Table Radio select and hide the select all box
- el-table单选并隐藏全选框
- SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache
- C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
- Ultimate bug finding method - two points
- Hands on deep learning (45) -- bundle search
- The child container margin top acts on the parent container
- Go context basic introduction
- Golang Modules
猜你喜欢

Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)

PHP personal album management system source code, realizes album classification and album grouping, as well as album image management. The database adopts Mysql to realize the login and registration f

Leetcode (Sword finger offer) - 35 Replication of complex linked list

2022-2028 global elastic strain sensor industry research and trend analysis report
自动化的优点有哪些?

法向量点云旋转

Hands on deep learning (40) -- short and long term memory network (LSTM)

Normal vector point cloud rotation

2022-2028 research and trend analysis report on the global edible essence industry

Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
随机推荐
How web pages interact with applets
Write a jison parser from scratch (5/10): a brief introduction to the working principle of jison parser syntax
Mmclassification annotation file generation
Advanced technology management - how to design and follow up the performance of students at different levels
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
Web端自动化测试失败原因汇总
Flutter 小技巧之 ListView 和 PageView 的各種花式嵌套
Latex download installation record
C # use smtpclient The sendasync method fails to send mail, and always returns canceled
How can people not love the amazing design of XXL job
Golang 类型比较
Histogram equalization
Luogu deep foundation part 1 Introduction to language Chapter 4 loop structure programming (2022.02.14)
Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
2022-2028 global industry research and trend analysis report on anterior segment and fundus OTC detectors
What are the advantages of automation?
Summary of the most comprehensive CTF web question ideas (updating)
165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
2022-2028 global edible probiotic raw material industry research and trend analysis report