1 | >> 带符号右移。正数右移高位补0,负数右移高位补1。比如: |
for循环的过程和顺序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
38public class Main {
private static int index = -1 ;
public static int init(int arg){
System.out.println("init");
return arg;
}
public static boolean judge(int arg){
System.out.println("judge");
return arg < 3;
}
public static void step(){
index++;
System.out.println("step , index is "+ index);
}
public static void main(String[] args){
for( index = init(0) ; judge(index) ; step()){
System.out.println("in for body index is " + index);
}
}
}
以下是输出结果:
init
judge
in for body index is 0
step , index is 1
judge
in for body index is 1
step , index is 2
judge
in for body index is 2
step , index is 3
judge