1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Paraphin [41]
3 years ago
14

Create an ArrayList of Employees (contain id and name) and add 3 Employees to the ArrayList to start. Next, you want to sort the

se Employees by their name using Collections.sort. Refer back to ch 4 and lab 2 part 2 to use comparator and Collections.sort. In order to avoid affecting the original list and employees, clone the ArrayList before using the sort method. To make a deep copy of the ArrayList, implement the clone method of Employee and use it to create a new ArrayList of employees.

Computers and Technology
1 answer:
Anna [14]3 years ago
3 0

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't accept the symbol

Explanation:

Java code:

import java.util.*; public class Employees { // variables private int id; private String name; // getters public String getName() { return name; } public int getId() { return id; } // constructor public Employees(int id, String name) { this.id = id; this.name = name; } // comparator function based on the name static class compareByName implements Comparator<Employees> { "at"Override public int compare(Employees emp1, Employees emp2) { return emp1.getName().compareTo(emp2.getName()); } } // clone method for arraylist public static ArrayList<Employees> clone(ArrayList<Employees> arr) { ArrayList<Employees> temp = new ArrayList<Employees>(); for(int i=0;i<arr.size();i++) temp.add(arr.get(i)); return temp; } // main method public static void main(String[] args) { Scanner scan = new Scanner(System. in); // reading 3 employees details ArrayList<Employees> arr = new ArrayList<Employees>(); for(int i=0;i<3;i++) { System.out.print("Enter id: "); int id = scan. nextInt(); System.out.print("Enter name: "); scan. nextLine(); String name = scan. nextLine(); arr.add(new Employees(id,name)); } // cloning and sorting ArrayList<Employees> cloneArray = clone(arr); Collections. sort(arr, new compareByName()); // printing System. out. println("Array after cloning: "); for(int i=0;i<cloneArray. size();i++) { System.out.println(cloneArray. get(i). getId() + " " + cloneArray. get(i).getName()); } System. out. println("Array after sorting: "); for(int i=0;i<arr.size();i++) { System. out. println(arr.get(i). getId() + " " + arr.get(i). getName()); } } }  

Kindly check the attached images below for the code screenshot and code output.

You might be interested in
In Google search results, how are organic links different from sponsored links?
xxMikexx [17]
Sponsored links are links that have been paid for in order to bring them to the first positions when the engine returns the results of the search.  Organic links are links that have not been paid for.  Your answer is D.
4 0
3 years ago
Read 2 more answers
Match the following
kakasveta [241]

Answer:

Eraser tool -removes the unwanted part of the drawing.

Row -horizontal space running from left to right.

Text -Primary component of a multimedia.

Drawing Area -Working are of ms point program.

I hope this helps!! Correct me plz if I'm wrong. If I'm right, could you mark me as brainliest?

8 0
3 years ago
Create one of these on your desktop start menu and use it to quickly open a folder, data file, program, or other object?
mario62 [17]
<span>A shortcut is a used to quickly open a folder, data file, program, or other object. They are very convenient to have and make navigating through a computer extremely easy.</span>
3 0
4 years ago
The numeric keys on a keyboard or calculator are referred to as a:
Anna [14]

Numeric Keypad is the answer

6 0
3 years ago
The development team recently moved a new application into production for the accounting department. After this occurred, the Ch
Gnesinka [82]

Answer:

B

Explanation:

User Acceptance Testing (UAT) is the testing done by end users who is going to use that application. In these testing they will test  whether the application meets all the functional requirements of the end user. If it passed then only the application will move to the production. This will ensure that the application meets the user requirements before it put into the usage.

The Answer is B

5 0
3 years ago
Other questions:
  • You are tasked with securing a small network for a client in which the following requirements must be met: If a user on the priv
    8·1 answer
  • Which of the following is a popular open source intrusion detection system that runs on SmoothWall?? Synchronous Dynamic Random
    6·1 answer
  • (1) Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a
    5·1 answer
  • Gigantic Life Insurance is organized as a single domain. The network manager is concerned that dividing into multiple domains to
    15·1 answer
  • Which of the following Web sites would be MOST credible?
    6·1 answer
  • 4.In order for a driver to graduate from a learner’s license to an operator’s license, how many hours of driving need to be docu
    15·1 answer
  • Translate We get up at 8 o'clock into Spanish in the box below:​
    9·1 answer
  • Anyone play Ps4 and wanna run up some warzone or Gta? Im M 16 so dont be a creep... :) ill mark brainliest if you drop gamertag
    8·2 answers
  • Which privacy protection uses four colors to indicate the expected sharing limitations that are to be applied by recipients of t
    12·1 answer
  • During the maintenance phase of the sdlc, the team must _____ if a system's objectives are not being met
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!