An organization maintains employee records with two attributes: currentExp (experience in the current company) and totalExp (overall work experience). Write a Java program that accepts currentExp and totalExp for 4 Employee objects, stores them in a TreeSet, and prints them in sorted order.
Employees are sorted by currentExp in ascending order. If the currentExp values are the same, they are sorted by totalExp in ascending order.
Requirements:
compareTo method comparing currentExp first, then totalExp.TreeSet automatically removes duplicates.Input: 4 lines, each with two integers: the employee's experience in the current company and the total work experience. For each employee, totalExp >= currentExp.
Output: all Employee records stored in the TreeSet, in sorted order, one per line, in the format CurrentExp:<currentExp> TotalExp:<totalExp>.
An organization maintains employee records with two attributes: `currentExp` (experience in the current company) and `totalExp` (overall work experience). Write a Java program that accepts `currentExp` and `totalExp` for 4 `Employee` objects, stores them in a `TreeSet`, and prints them in sorted order. Employees are sorted by `currentExp` in ascending order. If the `currentExp` values are the same, they are sorted by `totalExp` in ascending order. Requirements: - Define the `compareTo` method comparing `currentExp` first, then `totalExp`. - Return a negative number if this employee comes before the other, a positive number if it comes after, and 0 if they are equal. - A `TreeSet` automatically removes duplicates. Input: 4 lines, each with two integers: the employee's experience in the current company and the total work experience. For each employee, `totalExp >= currentExp`. Output: all `Employee` records stored in the `TreeSet`, in sorted order, one per line, in the format `CurrentExp:<currentExp> TotalExp:<totalExp>`.