0

I'm new at java and I just started working with arraylists, I'm trying to make it so that the user can input data with different values, save it on an arraylist and eventually print it, however with my current flawed code it shows me what I believe is the location.
This is the separate class code that gets added to the main class.

class Person   
{
    private String nName;
    private int nHour;
    private int nDay;
    private int nValues;
    public Person(int Day, int Hour, int Values, String Name)
    {
        nNombre = name;
        nHour = hour;
        nDay = day;
        nValues= values;
}

And the other class

import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;

public class Organizer
{
private ArrayList<Person> people;

public Organizer()
{
    people = new ArrayList<>();
}

public void newPerson(int day, int hour, int values, String name)
{

    people.add(new Person(day, hour, values, name));
}

public void listPeople
{
    Iterator listIterator = people.listIterator();
    while(listIterator.hasNext())
    {
        System.out.println(listIterator.next());
    }
}

When I try to print with my own input values get this

Person@13f58a5

Which I assume is the location but I need it to print the values input earlier, I'm stumped and I'm not sure what I did wrong.

0 Answers0