public class Employee { private static int id; private int employeeId; private String name; private String position; private int salary; private String department; public Employee(){ this("A", "B", 1); System.out.println("Empty constructor called"); } public Employee(String name, String position, int salary){ this(name, position, salary, "IT"); System.out.println("Constructor with 3 params called"); } private Employee(String name, String position, int salary, String department){ employeeId = id++; this.name = name; this.position = position; this.salary = salary; this.department = department; System.out.println("Constructor with 4 params called"); } public int getEmployeeId(){ return employeeId; } } public class Test { public static void main(String[] args) { Employee employee = new Employee(); } } I do not understand why the information in the console is so strangely displayed:
Constructor with 4 params called Constructor with 3 params called Empty constructor called