So I have a class called Employee in which I created an ArrayList
for in another class. I am trying to print the values of the list but they print each element's object reference. I forgot how to do this, I have tried looking it up elsewhere but can't seem to find an answer.
Here is the Employee Class:
public class Employee {
int employeeID;
String employeeName;
public Employee(int employeeId, String employeeName){
this.employeeID = employeeId;
this.employeeName = employeeName;
}
...
Here is where I print my values:
public void printArrListValues() {
for(Employee x: employeeList){
System.out.println(x);
}
// Arrays.toString(employeeNameLst);
}
I did try using .toString()
on x, however this did not solve the issue.
The console printed this to me:
binarytree.Employee@78da5318
binarytree.Employee@45858aa4
binarytree.Employee@425138a4
binarytree.Employee@625db8ff
binarytree.Employee@771c9fcc
binarytree.Employee@783f472b
binarytree.Employee@25995ba
binarytree.Employee@4774e78a
BUILD SUCCESSFUL (total time: 0 seconds)