i have created an object from a method and put that object into an array list and now i want to print the values of the object in the array list, when I use System.out.println(objectname) i get the storage location of the object instead of the values
ArrayList<Student> students = new ArrayList<Student>();
Student tomas = new Student("tomas", "jordan");
students.add(tomas);
Student get = students.get(0);
System.out.println(get);
the result i get is Student@789ddfa3 the result i want is tomas,jordan
this is the student class below
public class Student {
public String fname;
public String lname;
//constructor
public Student(String fn,String ln){
fname = fn;
lname = ln;
}
}