Есть массив list[ ] класса Person. Создан ArrayList myList содержащий массив list[ ]. Как внести данные с клавиатуры в myList?
package com.javarush.task.task08.task0829;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Модернизация ПО
*/
public class Solution {
public static void main(String[] arg) throws IOException {
ArrayList<Person> myList = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Person list[] = new Person[2];
int i = 0;
int k = 0;
while (true) {
String family = reader.readLine();
if (family.isEmpty()) {
break;
}
list[i] = new Person();
list[i].setName(family);
String city = reader.readLine();
list[i].setСity(city);
myList.add(list[i]);
i++;
}
}
public static class Person {
String name;
String city;
Person(String name, String city) {
this.name = name;
this.city = city;
}
Person() {
}
public String getName() {
return this.name;
}
public String getCity() {
return this.city;
}
public void setName(String name) {
this.name = name;
}
public void setСity(String city) {
this.city = city;
}
}
}