-4
package javaapplication97;
import java.util.Scanner;
public class JavaApplication97 {
public static void main(String[] args) {
System.out.println("Enter a number: ");
Scanner s1 = new Scanner(System.in);
if (s1.hasNextInt())
System.out.println("This is an int");
}
}
有什麼問題嗎? –
你有關於'for'和'while'循環的想法嗎? [ - > while和do-while語句](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html)AND [ - > for語句](http:// docs .oracle.com/javase/tutorial/java/nutsandbolts/for.html) – Smit
請格式正確。 – NINCOMPOOP