当前位置:网站首页>Concept and understanding of variables
Concept and understanding of variables
2022-06-25 21:22:00 【vancomycin】
1. Variable
1.1 Concept and basic understanding of variables
The concept of a variable is a storage unit , For type reference , A variable refers specifically to a definite value
The variables are ( data type Variable name value ) form
int i = 15;
plastic Variable name value Declaration and assignment of variables
java It's a strongly typed language , The type of variable must be consistent with the type of data .
1.2 Declaration and assignment of variables
For variables, first declare them in the assignment , Is the basic operation of variables ,
int i ;
data type Variable name
i = 15;
Variable name value
Declare and assign values
int i = 15;
plastic Variable name value Declaration and assignment of variables
Declaration and assignment of multiple variables of the same type
data type Variable 1 , Variable 2 , Variable 3 = value 3 , Variable 4 , Variable 5 = value 5;
int i , o , p=1,s , f=5;
2 Java Data type of
Basic data type : Integers decimal Boolean character
Reference data type : character string Array object
Eight data types : byte short int long float double boolean char
1 byte 2 byte 4 byte 8 byte 4 byte 8 byte 1 byte 2 byte
8 position 16 position 32 position 64 position 32 position 64 position 8 position 16 position
The value range of the integer is minus the power of the positive and negative bits of the corresponding data type
such as byte The range of phi is zero Eight minus one power of two That's the seventh power of two Plus or minus -128~127 And so on
int The default form of a bit integer , If necessary long Type assignment You need to add... To the end of the value L ( Uppercase or lowercase Recommended capitalization )
1G=1024MB
1MB=1024KB
1KB=1024byte 1byte It's just a byte So a byte is 8 position
1byte=8bit 8bit intend 8 position
Floating point types have a large range
Floating point numbers are represented by scientific counting :
2E3 Equivalent to 2 * 10 ^ 3( result :2000.0)3E5 Equivalent to 3 * 10 ^ 5( result :300000.0)
Be careful :double Is the default type of floating point numbers , If necessary float Type assignment , You need to append... After the value “F”
boolean Boolean data type There are only two value ranges True or False describe “ really “ or ” false “
java Of boole Not involved in arithmetic operations
char Data type two bytes , The value range is 0~65535 char Data from Common letter Numbers And Chinese , And the languages in the world code
however char Only one value can be declared at a time
for example :char ch1 = '2'; correct
char ch1 = ‘22’; error
char ch1 = 'a' 'A' 65 ' in ' It's all right But only one quantity can be declared at a time
3 Escape character
A newline \n You can wrap lines in any output statement amount to System.out.println()
tabs \t You can control spaces and align them up and down in the output statement
Backslash \\ Single quotation marks \’ If you want to output separately, you must insert an escape character before you can output But double quotation marks are optional
4 Reference data type
String Value range In any ” “ The middle value is OK
String str1 =” Hello “
String str1 =” The number “
String str1 =”helo“
边栏推荐
- The beginning of manjaro's journey
- 炒股票用指南针安全还是用证券软件安全?哪里可以开户怎么开
- Win10 common software
- Get the root directory of the package at compile time from buildreoot
- Is it safe for qiniu school to open an account in 2022?
- Vbpr (visual Bayesian personalized ranking) paper summary
- Basic knowledge of software engineering required for soft test
- Server pressure troubleshooting top
- PHP compressed file
- Cross project measurement is a good helper for CTOs and PMOS
猜你喜欢

Unable to connect to the server remotely locally using the Jupiter notebook

Decryption of APP parameters of a cross-border export e-commerce - dunhuang.com

04 disk space management

Beginner to embedded development

Molecular dynamics - basic characteristics of molecular force field

"Developer theory" multi system integrated development - rapid nailing of enterprise owned systems

What is a server? (Powercert animated videos)
![[important notice] developer document update (12.13-12.19)](/img/49/6a54235409ec95fa50bcc14ef1d405.jpg)
[important notice] developer document update (12.13-12.19)

Soft test intermediate simple notes

Explain memcached principle in detail
随机推荐
股市小白通过网上进行股票开户安全吗?
STM32 self balancing robot project, with code, circuit diagram and other data attached at the end (learning materials and learning group at the end)
How to write an infinite loop
Docker failed to remotely access 3306 after installing MySQL
How to solve the problem of flash write protection in STM32?
"Developer theory" multi system integrated development - rapid nailing of enterprise owned systems
Data query of server SQL. The most important chapter in database learning
Molecular dynamics - basic characteristics of molecular force field
银河证券靠谱吗?开证券账户安全吗?
The super easy-to-use test tool sorted out by Ali P8 for a week
Compile 6relayd using the cross compiler
PHP compressed file
Introduction to interface test, interface protocol and common interface test tools
JVM Foundation
Openocd compilation and installation
CANoe. Diva operation guide TP layer test
Is it legal to open an account for flush stock trading software? Is it safe?
Heavy update! Yolov4 latest paper! Interpreting yolov4 framework
Talking about the foundation of function test today
On dynamic programming