当前位置:网站首页>Variables and constants
Variables and constants
2022-07-07 22:25:00 【51CTO】

1、 What is a variable
A variable is a reference to a specific value .
2、 The composition of variables
Variables are composed of three elements, which are data types , Identifier and value .
The data type of a variable determines the value range of its value , size , Type, etc .Java Is a language that focuses on data types , Therefore, when declaring any variable, we should determine the data type of the variable .
The identifier of the variable is the unique identifier of the variable , We can determine the variable itself through the identifier . Generally speaking, an identifier is the name of a variable . This name is the only identifier of the variable . The identifier appears mainly to facilitate our manipulation of this variable , Flexibly carry out the subsequent operation of variables .
The value of a variable is to determine the specific value that its reference points to . stay Java Any variable that is not assigned a value in cannot be operated directly . Before being assigned , It can only be called declaring a variable .
3、 Variable operation
① Statement

② assignment
Assignment of any variable , Will use “=” assignment .

③ Other related operations of variables
Such as arithmetic operation , Value change, etc .
4、 data type
Because we know that one of the three elements of variables is data type , So what are the data types ?
stay Java Data types in are divided into , Basic data type and reference type ( object / Packaging ).
There are four basic data types : integer , floating-point , Boolean type , Character type .
integer : Integer is the type used to represent the value of the integer part .
According to the value range, we can divide integers into short integers (short), integer (int), Long integer (long).

Floating point type : Used to describe the type of value with decimal point .
Floating point type can be divided into single precision according to the precision of decimal point (float) Double precision (double).
stay Java Double precision is used by default , Double precision is also used more in development . To use single precision , You have to use float Strong go .

Character types are used to represent letters , Symbol .

Boolean type is used to indicate right or wrong . There are only two values , One for true, One for false.

Reference types are not covered here for the time being , After talking about classes and objects, we will mention them there .
5、 Variable naming rule :
- Upper and lower case letters and numbers form
- Composed of multiple words , First word lowercase , The rest of the words are capitalized . Such as (strNumber).
6、 Constant
Constants are conventionality values , Such as PI,e, Four parameters of database connection, etc .
Usually constants use static final modification .
Constants are usually used by multiple methods in a class and their values do not change because they are used . This solves the problem that the value of variables will change due to their use .

Naming rules : Full name capitalization .
Learn more about
https://edu.51cto.com/lecturer/14175030.html
边栏推荐
- An in-depth understanding of fp/fn/precision/recall
- The function is really powerful!
- Aspose. Word operation word document (I)
- [open source] Net ORM accessing Firebird database
- Vs custom template - take the custom class template as an example
- Latest Android advanced interview questions summary, Android interview questions and answers
- Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
- Main functions of OS, Sys and random Standard Libraries
- How does win11 time display the day of the week? How does win11 display the day of the week today?
- VTOL in Px4_ att_ Control source code analysis [supplement]
猜你喜欢

反爬通杀神器

【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式

Blender exchange group, welcome to the water group ~

The latest Android interview collection, Android video extraction audio

What if the win11u disk does not display? Solution to failure of win11 plug-in USB flash disk

Remember an experience of using selectmany

如何选择合适的自动化测试工具?

Embedded development: how to choose the right RTOS for the project?

Two kinds of updates lost and Solutions

Cannot find module 'xxx' or its corresponding type declaration
随机推荐
谈谈制造企业如何制定敏捷的数字化转型策略
L2: current situation, prospects and pain points of ZK Rollup
Matplotlib快速入门
变量与常量
PKPM 2020软件安装包下载及安装教程
用语雀写文章了,功能真心强大!
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
如何实现横版游戏中角色的移动控制
Revit secondary development - modify wall thickness
Jerry's power on automatic pairing [chapter]
Record problems fgui tween animation will be inexplicably killed
Overseas agent recommendation
Remember aximp once Use of exe tool
建立自己的网站(18)
MIT6.S081-Lab9 FS [2021Fall]
100million single men and women "online dating", supporting 13billion IPOs
Jerry's manual matching method [chapter]
Latest Android advanced interview questions summary, Android interview questions and answers
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
How to make agile digital transformation strategy for manufacturing enterprises