import java.util.*;
public class PersonList{
public static void arraylist() {
// create an array list
ArrayList Employee = new ArrayList();
// add elements to the array list
Scanner input = new Scanner (System.in);
System.out.println("Name: ");
Employee.add(input.next());
System.out.println("Year of birth: ");
Employee.add(input.next());
System.out.println("");
Employee.add(input.next());
System.out.println("");
Employee.add(input.next());
System.out.println("");
Employee.add(input.next());
System.out.println("Contents of al: " + Employee);
}
}
I have an arraylist that takes user entered data and I need to store data that has a space into one block.
I haven't added the other things that I will include. I want to be able to put a name such as "John Smith" into the Name, instead of it printing John, Smith in two separate blocks. I am very new to programming and I apologize if it is sloppy and/or annoying.
input.nextLine()Employeevariableemployeeto respect naming conventions and get rid of those awful raw types.