I'm stuck on this problem i make a class Person in which it has only two properties name and age. I'm taking details of that person as a user input and saving as a object in ArrayList but i want to move that ArrayList object properties that user enter from keyboard into separate arrays like all names of person into String array and all ages of person into int array from that ArrayList. Is there a way to do that?
Code:
public class Person {
    String name;
    int age;
}
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        ArrayList<Person> arr = new ArrayList<Person>();
        Person person = null;
        for(int i=0;i<2;i++){
            person = new Person();
            System.out.println("Enter Person "+(i+1)+" Record");
            int age = 0;
            System.out.print("Enter Name : ");
            String str = s.nextLine();
            person.name = str;
            System.out.print("Enter Age : ");
            age = s.nextInt();
            s.nextLine();
            person.age = age;
            arr.add(person);
            person = null;
            System.out.println("Record "+(i+1)+" Successful Fill");
        }
            String[] stringarray = new String[arr.size()];
            int[] intarray = new int[arr.size()];
    }
}
 
     
     
     
    