Confusing input question
So I have these questions that are all based off the same structure. Except I am heavily confused on how to go about doing this. I can only think of reading the whole line not each work and this stupid online question does not know what hasNext() method is... I really have no idea on how to do this. Can anyone give me any ideas?
Oh and this is what is in dogyears.txt
The following code uses a Scanner object to read a text file called dogYears.txt. Notice that each line of this file contains a dog's name followed by an age. The program then outputs this data to the console. The output looks like this:
Your task is to use the Scanner methods that will initialize the variables name1, name2, name3, age1, age2, age3 so that the execution of the three println statements below will result in the desired output.
My code goes here
String name1, name2, name3;
int age1, age2, age3;
Scanner inputData = new Scanner(new FileReader("dogYears.txt"));
Nevermind got it :D that was easier than I thought :P
String d =inputData.nextLine();
age1 = Integer.parseInt(d);
String e =inputData.nextLine();
String j = inputData.nextLine();