I want to convert multiple tokens from the scanner input into a string. How can I do this? I've tried using scanner.next() but that returns just one token. I've also tried using scanner.nextLine() but that returns a java.lang.Number format exception. Here is the code I'm trying to use. It is supposed to add movie information to separate arrayLists. My scanner is called "a".
public static void addMovie()
{
System.out.println("What is the movie title?");
if(a.hasNext())
{
names.add(a.next());
}
System.out.println("What year was it released?");
if(a.hasNext())
{
year.add(Integer.valueOf(a.next()));
}
System.out.println("What was it rated?");
if(a.hasNext())
{
rating.add(a.next());
}
System.out.println("What is the genre?");
if(a.hasNext())
{
genre.add(a.nextLine());
}
System.out.println("Describe the move:");
if(a.hasNext())
{
genre.add(a.nextLine());
}
}