-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava_start.txt
82 lines (59 loc) · 1.2 KB
/
java_start.txt
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// 类名和接口名:每个字词首字母大写
// 方法名,变量名:驼峰式
// 常量名: 大写 final int SCORE=100;
System.out.println("hello");
char
int
float
double
string
if (a>b) {
}
else if () {
}
else{
}
switch () {
case 1:
System.out.println("value1");
break;
case 2:
System.out.println("value2");
break;
case 3:
case 4:
System.out.println("value3");
break;
default:
System.out.println("value default");
}
while () {
}
do {
} while ();
for (int i = 1; i <= 1000; i++) {
System.out.println("do something");
}
int[] score = {32,22,31};
score = new int[5];
String[] words = new String[] {"one", "two", "three"};
String[] words = new String[3];
System.out.println(words.length);
import java.util.Arrays;
Arrays.sort(words);
Arrays.toString(score);
# foreach
for (int onescore : score) {
System.out.println(onescore);
}
String[][] words = new String[3][];
# 二维数组至少需要定义行数
返回值类型
void # 不返回任何值
public void function1(args) {
}
public class Hello{
Hello hh = new Hello();
}
int num = (int)(Math.random()*100);
# (int)用于强制类型转换