本帖最后由 回忆一遥远 于 2017-8-16 07:38 编辑
相应代码..
对对象 = 操作的结果:class Tank{
int level;
}
public class And {
public static void main(String[] args){
Tank t1 = new Tank();
Tank t2 = new Tank();
t1.level = 7;
t2.level = 64;
System.out.println("1: t1.level: " + t1.level + ", t2.level: " + t2.level);
t1 = t2;
System.out.println("2: t1.level: " + t1.level + ", t2.level: " + t2.level);
t1.level = 43;
System.out.println("3: t1.level: " + t1.level + ", t2.level: " + t2.level);
}
}
给定 Random 种子值的运算:import java.util.*;
public class Operators {
public static void main(String[] args){
Random rand = new Random(24);
int i, j, k;
j = rand.nextInt(100) + 1;
System.out.println("j: " + j);
k = rand.nextInt(100) + 1;
System.out.println("k: " + k);
i = j + k;
System.out.println("j + k : " + i);
i = j - k;
System.out.println("j - k : " + i);
}
}
|