forked from coding-technology/JavaCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest1.java
More file actions
43 lines (32 loc) · 1.19 KB
/
Test1.java
File metadata and controls
43 lines (32 loc) · 1.19 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
public class Test1 {
public static void main(String[] args) {
//变量:1.声明数据类型(整数、小数、字符串、....) 2.赋值(赋值符号=,将=右侧 赋给左侧) 3.使用
int myNum = 10;
// int myNum = 10 ; 变量名不能重复
myNum = myNum + 1;
System.out.println(myNum);
byte b = 127;
System.out.println(b);
short s = 1000;// short = int (整数默认是int,但是 = 对于整数自带 整数类型(byte short int long)之间的 转换器)
System.out.println(s);
long lon = 2000000;
System.out.println(lon);
float f = (float) 123.4; //小数默认是double. float = double
float f2 = 123.4f; //小数默认是double. float = double
System.out.println(f);
double d = 123.4;
System.out.println(d);
char c = 'x';
System.out.println(c);
String str = "a";
String str2 = "aaaa";
String str3 = "";
System.out.println(str);
System.out.println(str2);
System.out.println(str3);
int x1 = 1;
int X1 = 1;
int y = 222;
System.out.println(y);
}
}