Hey everyone, It's 3am and I'm pulling my hair out trying to get this to work. I'm reading data from a file that looks like so:
James
20
John
30
Peter
25
and I am storing it in an arraylist then outputting the data. It outputs exactly as it is in the text file, what I want to do now is display the data with the name and age side by side like so:
James 20
John 30
Peter 25
Here is the code I have so far
BufferedReader reader = new BufferedReader(new FileReader(
"files/temperatures.txt"));
String line = "";
while ((line = reader.readLine()) != null) {
arrayOfStrings.add(line);
}
for (String readline : arrayOfStrings) {
System.out.println(readline);
}
reader.close();
If you have any idea as to how to do this I thank you in advance for your reply