-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
29 lines (26 loc) · 795 Bytes
/
Employee.java
File metadata and controls
29 lines (26 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
class Emp{
private final String name;
private final double salary;
public Emp(String name,double salary) {
this.name=name;
this.salary=salary;
}
@Override
public String toString(){
return "Employee Name: "+this.name+" and Salary: "+this.salary;
}
}
public class Employee{
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] arg){
List l1=new ArrayList<>();
l1.add(new Emp("Bobby Deol",557474.3));
l1.add(new Emp("Sunny Deol",9876332.23));
l1.add(new Emp("Dharmendra Deol",747473.23));
System.out.println(l1);
Iterator<Object> itr=l1.iterator();
while(itr.hasNext()){
System.out.println(itr.next());}
}
}