当前位置:网站首页>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
边栏推荐
- [开源] .Net ORM 访问 Firebird 数据库
- Get the week start time and week end time of the current date
- Remember aximp once Use of exe tool
- . Net automapper use
- How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
- Add get disabled for RC form
- Jerry's about TWS channel configuration [chapter]
- Can I open a stock account directly online now? Is it safe?
- Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
- Use partial derivatives to display normals in unity
猜你喜欢
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
Vs custom template - take the custom class template as an example
Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
VTOL in Px4_ att_ Control source code analysis [supplement]
The whole network "chases" Zhong Xuegao
PKPM 2020软件安装包下载及安装教程
IP网络主动测评系统——X-Vision
[JDBC Part 1] overview, get connection, CRUD
Jerry's about TWS channel configuration [chapter]
随机推荐
[advanced MySQL] index details (I): index data page structure
Ueeditor custom display insert code
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
L2: current situation, prospects and pain points of ZK Rollup
Pdf document signature Guide
Jerry's test box configuration channel [chapter]
An in-depth understanding of fp/fn/precision/recall
Leetcode SQL first day
JS number is insufficient, and 0 is added
Use blocconsumer to build responsive components and monitor status at the same time
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
OpenGL job - texture
Time standard library
Node:504 error reporting
强化学习-学习笔记9 | Multi-Step-TD-Target
Jerry's manual matching method [chapter]
Remember an experience of using selectmany
648. Word replacement
Aspose. Word operation word document (II)