下面是代碼。我真的需要幫助,因爲我不知道它有什麼問題。正如我所說,它編譯乾淨,但每當我運行它,它都無法執行。謝謝!這個java代碼編譯,但是是錯誤的。你能告訴我它有什麼問題嗎?
import java.util.Scanner;
public class whatThe
{
public static void main(String[ ] args){
Scanner scan = new Scanner(System.in);
int i;
String s;
char c;
System.out.print("Please enter a number: ");
i = scan.nextInt();
System.out.println(i);
System.out.println();
System.out.print("Please input three words separated by spaces: ");
s = scan.next();
System.out.println(s);
System.out.println();
System.out.print("Please input something: ");
s = scan.nextLine();
System.out.println(s);
System.out.println();
System.out.print("Please enter another number: ");
i = scan.nextInt();
System.out.println(i);
System.out.println();
System.out.print("Please input a word: ");
s = scan.nextLine();
c = s.charAt(0);
System.out.println(c);
System.out.println();
System.out.println("Good bye");
}
}
*「但是隻要我運行它,它就無法執行」* - 怎麼樣?它會產生錯誤嗎?你如何運行它? – MadProgrammer
醜陋,根本不幹。你可以做得更好。 – duffymo
你幹什麼意思?我是新來的Java。 – arsb48