62,620
社区成员
发帖
与我相关
我的任务
分享
public class CountTest {
public static int count1 = 0;
public static int count2 = 0;
public static void main(String[] args) {
Random r = new Random();
for (int i=0; i < 10; i++) {
int num = r.nextInt();
if (num > 0.5) {
method1();
} else {
method2();
}
}
System.out.println(count1 + " " + count2);
}
public static void method1() {
count1++;
}
public static void method2() {
count2++;
}
}