i have created a class employee.it has four variables name,id,salary,city.i have made a array list of the employee class object.When i run the file it only shows the defaullt values.But i want to add more than one value in my array list.what should i do?please help me to solve this here is my code
import java.util.*;
public class arraylist {
public static void main(String[] args) {
new arraylist();
}
public arraylist() {
List<Employee > listOfEmp = new ArrayList<Employee >();
Employee bk1 = new Employee ();
listOfEmp .add(bk1);
System.out.println(" emp = " + bk1);
System.out.println("listOfEmployee(0) = " + listOfEmp.get(0));
}
public class Employee {
String name="sarah";
int id =102;
String city="orny";
int salary=13000;
// @Override
public String toString() {
return "Employee: name = " + name + "; Id = " + id + "; City = " + city + "; Salary = " + salary + "; hashCode = " + hashCode();
}
}
}