import java.io.IOException;
public class A { /**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
while (true) {
System.out.println("请输入一个正整数:");
int n = System.in.read(); System.out.println("n=" + n);
}
} }
结果截图:
public class A { /**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
while (true) {
System.out.println("请输入一个正整数:");
int n = System.in.read(); System.out.println("n=" + n);
}
} }
结果截图: