Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- public class Employee {
- int id;
- int salary;
- String position;
- public Employee(int salary, String position) {
- this.salary = salary;
- this.position = position;
- }
- @Override
- public String toString() {
- return "(" + id + ") (" + position +") : "+ salary;
- }
- public static void main(String[] args) {
- List<Employee> employeeList = new ArrayList<>();
- Employee employee1 = new Employee(8000, "Programmer");
- Employee employee2 = new Employee(6000, "Programmer");
- Employee employee3 = new Employee(9000, "Programmer");
- employeeList.add(employee1);
- employeeList.add(employee2);
- employeeList.add(employee3);
- for (Employee employee: employeeList) {
- System.out.println(employee.toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment