当前位置:网站首页>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 edible probiotic raw material industry research and trend analysis report
- Hands on deep learning (40) -- short and long term memory network (LSTM)
- Implementing expired localstorage cache with lazy deletion and scheduled deletion
- lolcat
- Hands on deep learning (36) -- language model and data set
- Write a jison parser from scratch (1/10):jison, not JSON
- Matlab tips (25) competitive neural network and SOM neural network
- Modules golang
- How do microservices aggregate API documents? This wave of show~
- Global and Chinese markets for laser assisted liposuction (LAL) devices 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
2022-2028 global edible probiotic raw material industry research and trend analysis report
5g/4g wireless networking scheme for brand chain stores
C language pointer classic interview question - the first bullet
回复评论的sql
2022-2028 global seeder industry research and trend analysis report
How can Huawei online match improve the success rate of player matching
How does idea withdraw code from remote push
智慧路灯杆水库区安全监测应用
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
随机推荐
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
Launpad | Basics
2022-2028 global intelligent interactive tablet industry research and trend analysis report
【leetcode】29. Divide two numbers
2022-2028 global protein confectionery industry research and trend analysis report
Logstack configuration details -- elasticstack (elk) work notes 020
Write a jison parser from scratch (5/10): a brief introduction to the working principle of jison parser syntax
5g/4g wireless networking scheme for brand chain stores
Get the source code in the mask with the help of shims
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
Hands on deep learning (39) -- gating cycle unit Gru
Log cannot be recorded after log4net is deployed to the server
百度研发三面惨遭滑铁卢:面试官一套组合拳让我当场懵逼
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
浅谈Multus CNI
SQL replying to comments
【leetcode】540. A single element in an ordered array
Matlab tips (25) competitive neural network and SOM neural network
Lauchpad X | 模式
Rules for using init in golang