I have tried to use the add method to add some Strings to my ArrayList of type Name. Name stores firstName and familyName. All I tried to do is pass the firstName and familyName using the scanner but it just doesn't seem to be that easy. What am I doing wrong?
import java.util.ArrayList;
import java.util.Scanner;
public class NameListTest {
public static void main(String[] args) {
ArrayList<Name> register = new ArrayList<Name>();
Scanner sc = new Scanner(System.in);
for(int i = 0; i < 4; i++) {
System.out.println("Enter first name:");
String firstName = sc.nextLine();
System.out.println("Enter last name:");
String secondName = sc.nextLine();
register.add(firstName, secondName);
}
}
}