我是java新手,我制作了我的第一个“程序”——一个简单的输入/输出程序,可以输出你输入的内容。
import java.util.Scanner;
class Input{
public static void main(String args[]){
int zip;
int a;
double e = 2.718281828459045;
String name;
Scanner in = new Scanner(System.in);
System.out.println("Enter your zip code: ");
zip = in.nextInt();
System.out.println("Enter your name: ");
name = in.nextLine();
System.out.println("Enter an integer: ");
a = in.nextInt();
System.out.println(name+", "+"your zip code is "+zip+" and e*"+a+" is "+e*a);
}
}
所以当我运行它时,我输入邮政编码,然后它进入整数输入。我怀疑输入流在按下回车后会吞下结束符。任何快速修复还是我只是java-stupid?
谢谢,所以!