Java Basics (two) variables and data types

Java Basics (two) variables and data types
Review:
1. What is the programming

2.Java programming language and its history

Step 3. Use Notepad to develop Java programs

4. The package name rules

In this chapter:
1.why the What??

2. Variable three elements

3. Master variables and constants

And finally the difference between 4.final and finalize the

The master data type conversion

1.why? What?
RAM: run-time memory when you power off the computer, shut down, data will be lost or crashes

ROM: Read Only Memory, C drive, D drive

To store the variable data, represented by a character instead of a number or string, to modify and maintain the code

Variables: To store data, the address is not convenient to use when the program runs, it leads to a variable name.

2. The three elements of variable
data types

① The first classification

Value Type
Integer: int (default integer)

Floating-point (decimal): double (double precision by default), float

Non-numeric types

String (String): as long as the double quotation marks are strings. "Name"
character (char): sheets quotation marks is the character 'M' 'female' 'A'
** boolean (boolean): true true / false false **

② The second classification

The basic data types: very common, are the key color in the IDE int double char boolean ...
reference data types: arrays, classes (String data type is a reference), the interface ...
the variable name (important)

Rules:
① see the name EENOW
② variable names consist of letters, numbers, underscores as well as the $ sign, but the number can not start, can not appear keywords.
Keywords: system defines the special meaning of the word (in the IDE the color has changed)
, for example: public static int class ...
③ method using camelCasing
Example: storing user information wodemingzi -> nomenclature employed hump -> woDeMingZi
-> using the underscore splicing -> wo_de_ming_zi
hump nomenclature :( small hump nomenclature)
first letter lowercase, if there is more than one word, the first letter of each word capitalized behind.
myUserInfo
PS: class name (Pascal nomenclature / big hump nomenclature)
first letter of each word is capitalized! HelloWorld

<font size = 4> ** ④ English either all, or pinyin, must not mashup ** </ font>
. 1
variable value
3. Variables and Constants using
variable set → → → Array XML → → non-relational database relational database → → large data cache

Variables used:

1. declare variables: the data type of a variable value divided memory space int num

2. assign values ​​to variables: a stored value to this variable space num = 10

3. Variable ... variable value obtained according to the variable name can be used as the arithmetic output can also be used

Variable name assignment Data type 4 = variable value of variable declaration while int num = 10

constant

The program is running, there are some data did not want it to be re-assigned, can be modified with final

final double Pi = 3.1415926927

Constant naming convention:

1. All the letters are capitalized words

2. If there is more than one word, using the connections between the plurality of words _

3.MENU_PAGE_CONTEXT

Interview questions:

And finally the difference between final and finalize the

4. The master data type to
1. Type integer ranging from small to large: byte → short → int → long → float → double

2. Low → High accuracy (automated implicit type conversion)

3. High → low accuracy (casts, loses precision)

Interview questions

++ and -

Guess you like

Origin www.cnblogs.com/qhantime/p/11432770.html