package tankwar;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int number = (int) (Math.random() * 10);
int guess;
do {
System.out.println("猜数字(0~9):");
guess = scanner.nextInt();
} while (guess != number);
System.out.println("猜中了...XD");
}
}
A. 在建立Scanner实例时,必须传入java.io.InputStream的实例package tankwar;
import java.math.BigDecimal;
public class A {
public static void main(String[] args) {
int x = 1;
int y = 1;
int z = x;
System.out.println(x == y);// true
System.out.println(x == z);// true
BigDecimal a = new BigDecimal("1.0");
BigDecimal b = new BigDecimal("1.0");
System.out.println(a == b);// false
System.out.println(a.equals(b));// true
}
}