Employee.
java
public class Employee {
// Attributes
private int id;
private String name;
private String department;
private double salary;
// Constructor
public Employee(int id, String name, String department, double salary) {
this.id = id;
this.name = name;
this.department = department;
this.salary = salary;
// Getters
public int getId() {
return id;
public String getName() {
return name;
public String getDepartment() {
return department;
}
public double getSalary() {
return salary;
// Display method
public void displayDetails() {
System.out.println("Employee ID: " + id);
System.out.println("Name : " + name);
System.out.println("Department : " + department);
System.out.println("Salary : $" + salary);
System.out.println("---------------------------");
EmployeeDetailsApp.java
public class EmployeeDetailsApp {
public static void main(String[] args) {
// Create employee objects
Employee emp1 = new Employee(101, "Alice Johnson", "HR", 50000);
Employee emp2 = new Employee(102, "Bob Smith", "IT", 65000);
Employee emp3 = new Employee(103, "Charlie Brown", "Finance", 60000);
// Display employee details
emp1.displayDetails();
emp2.displayDetails();
emp3.displayDetails();