-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAll_variable.java
More file actions
67 lines (51 loc) · 1.48 KB
/
All_variable.java
File metadata and controls
67 lines (51 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.cpucode.java.variable;
/*
变量使用的注意事项:
名字不能重复
变量未赋值,不能使用
long类型的变量定义的时候,为了防止整数过大,后面要加L
float类型的变量定义的时候,为了防止类型不兼容,后面要加F
*/
public class All_variable {
public static void main(String[] args){
//定义byte类型的变量
byte b = 10;
System.out.println("byte b = " + b);
//定义short类型的变量
short s = 100;
System.out.println("short s = " + s);
//定义int类型的变量
int i = 1000;
System.out.println("int i = " + i);
long l = 1000000L;
System.out.println("long l = " + l);
System.out.println("--------------");
//定义float类型的变量
float f = 13.14F;
System.out.println("float f = " + f);
//定义double类型的变量
double d = 13.14;
System.out.println("double d = " + d);
System.out.println("--------------");
//定义char类型的变量
char c = 'a';
System.out.println("char c = " + c);
System.out.println("--------------");
//定义boolean类型的变量
boolean bb = true;
System.out.println("boolean bb = " + b);
}
}
/*
byte b = 10
short s = 100
int i = 1000
long l = 1000000
--------------
float f = 13.14
double d = 13.14
--------------
char c = a
--------------
boolean bb = 10
*/