基本上,我希望能够只显示一个字符串的引号。我不确定我是否需要数组或什么,但所有这些nextLine()
的东西让我感到困惑。如果有人可以指导我朝着正确的方向前进,或者甚至只是告诉我如何去做,那将非常感激。
以下是我所指的代码:
import java.util.Scanner;
public class PromptStuff
{
public static void main(String[] args)
{
String firstname;
String lastname;
int byear;
String quote;
Scanner userInput = new Scanner(System.in);
System.out.print("Input your first name: ");
firstname = userInput.nextLine();
System.out.print("Input your last name: ");
lastname = userInput.nextLine();
System.out.print("Alright.. What year were you born? ");
byear = userInput.nextInt();
System.out.print("Neat! Favorite quote?");
quote = userInput.nextLine();
System.out.print("Name: " + firstname);
System.out.println(" " + lastname);
System.out.println("Birth year: " + byear);
System.out.println("Favorite quote: " + quote);
}
}