public class App {
public static void main(String[] args) throws CloneNotSupportedException {
ArrayList<employee> al1 = new ArrayList<employee>();
Employee e1 = new Employee(1, "rak", "gwda", "1011996", "2111996");
Employee e2 = new Employee(2, "sher", "gowda", "", "");
Employee e3 = new Employee(3, "raksher", "homles", "", "");
Employee e4 = new Employee(4, "sherrak", "hgowda", "10111996", "21111996");
Employee e5 = new Employee(5, "raksh", "hgowda", "", "");
al1.add(e1);
al1.add(e2);
al1.add(e3);
al1.add(e4);
al1.add(e5);
System.out.println(al1);
What I have tried:
public class Employee {
private int id;
private String fname;
private String lname;
String doj;
String doe;
public Employee() {
super();
}
public Employee(int id, String fname, String lname, String doj, String doe) {
super();
this.id = id;
this.fname = fname;
this.lname = lname;
this.doj = doj;
this.doe = doe;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getDoj() {
return doj;
}
public void setDoj(String doj) {
this.doj = doj;
}
public String getDoe() {
return doe;
}
public void setDoe(String doe) {
this.doe = doe;
}
@Override
public String toString() {
return "Employee [id=" + id + ", fname=" + fname + ", lname=" + lname + ", doj=" + doj + ", doe=" + doe + "]";
}
}