java variable Note 02

Variable Name: lowercase first letter of recommendations to meet the "small hump mode." For example: className age studentName

Data types of research

First, the basic data types (eight kinds of class 4)

1, integer

-byte-byte integer

-short short integer

-int integer (default)

-long long integer

2, float

-float single precision

-double double (default)

3, character

-char character

4, Boolean type

-boolean Boolean

二、引用数据类型:数组、类、接口、、、、、、

We define the development of the direct use of general integer variable int, float variable usually directly double.

long range particularly large

Special Note: With the change to write an integer constant is the default type int

long lg1 = 32223325522332225232; // Error

Although 32223325522332225232 does not exceed the long range but he himself beyond the scope of int, so the error

Important: If you want to just write a default integer type long, need to add L \ l in the back, this time can be large integers (recommended L, like lowercase l 1)

float also have to pay attention

float rate = 0.8 // given

Note: We just write a decimal constant is the default type double

If you want to want to just write a decimal is the default type float, followed by the required F \ f

(Not the same as long and long range can not exceed int, float not to be added)

Class can not be defined with a range of two variables

double score = 99.5;

double score = 100.1 (this mistake, this is the definition again)

score = 100.1 (this is no problem with this is to re-copy)

Range variable, the variable will be limited parentheses, brackets beyond will fail! ! !

When you can not define a variable to the initial value, but when used must have an initial value.

Published 34 original articles · won praise 16 · views 303

Guess you like

Origin blog.csdn.net/qq_41005604/article/details/104982585