我试图编写一个输入和输出程序一些如何在“int name = in.nextInt();”中不断给我错误和括号。我一直在关注问题和修复,但似乎没有任何效果。我希望用户回答一系列问题,例如你的名字,输入你的年龄,输入你最喜欢的食物。
public class Main {
public static void main( String args[] );
{
}
Scanner Int = new Scanner( System.in );
}
int n;
{
}
System.out.print (
"What is your name", args) ;
int name = in.nextInt();
}
}
以下是错误:
C:\Users\Brenden\Google Drive\proj\tempj8\src\quicktest\ScratchPad.java:22: error: class, interface, or enum expected
int n;
C:\Users\Brenden\Google Drive\proj\tempj8\src\quicktest\ScratchPad.java:23: error: class, interface, or enum expected
{
C:\Users\Brenden\Google Drive\proj\tempj8\src\quicktest\ScratchPad.java:28: error: class, interface, or enum expected
int name = in.nextInt();
C:\Users\Brenden\Google Drive\proj\tempj8\src\quicktest\ScratchPad.java:29: error: class, interface, or enum expected
}
4 errors
C:\Users\Brenden\Google Drive\proj\tempj8\nbproject\build-impl.xml:938: The following error occurred while executing this line:
C:\Users\Brenden\Google Drive\proj\tempj8\nbproject\build-impl.xml:270: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)