Question: So in my java code I got everything to look the way it should. for some reason cant put formated currency in like: comma and
So in my java code I got everything to look the way it should. for some reason cant put formated currency in like: comma and dollar sign for the salary. I also just read I need to put forEach method, and I don't import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
class Employee
private String id;
private String lastName;
private String firstName;
private int salary;
public EmployeeString id String lastName, String firstName, int salary
this.id id;
this.lastName lastName;
this.firstName firstName;
this.salary salary;
public String getId
return id;
public String getLastName
return lastName;
public String getFirstName
return firstName;
public int getSalary
return salary;
@Override
public String toString
return ID id :
lastName
firstName
salary $ salary;
ArrayList
employee variables
not in order
used same names and info from instructions
public class listEmployee
public static void mainString args
Employee employeesArray
new Employee "Jones", "Don",
new Employee "Scott", "Bob",
new Employee "Jones", "Dan",
new Employee "Baker", "Amy",
new Employee "Scott", "Ann",
new Employee "Jones", "Pat",
new Employee "Perez", "Ava",
new Employee "Baker", "Tom",
;
Collections and List methods
List employeesList new ArrayList;
Collections.addAllemployeesList employeesArray;
Collections.sortemployeesListe e
int lastNameComparison egetLastNamecompareToegetLastName;
if lastNameComparison
return egetFirstNamecompareToegetFirstName;
return lastNameComparison;
;
final output
sorted output
reverse output
iterator forward and reverse order
System.out.printlnStaff Alpha sorted by names
;
employeesList.forEachSystemout::println;
List employeesLinkedList new LinkedListemployeesList;
Iterator iterator employeesLinkedList.iterator;
while iteratorhasNext
iterator.next;
System.out.println
Staff sorted Reverse Alpha
;
ListIterator listIterator employeesLinkedList.listIteratoremployeesLinkedListsize;
while listIteratorhasPrevious
System.out.printlnlistIteratorprevious;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
