Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data Structure course Can anybody please help me with this ? inport java.util.ArrayList: inport java.util.collections import java.util.Comparator import java.util.List: class Empl private Strirg nane private

Data Structure course
Can anybody please help me with this ?
image text in transcribed
image text in transcribed
image text in transcribed
inport java.util.ArrayList: inport java.util.collections import java.util.Comparator import java.util.List: class Empl private Strirg nane private int salary: public class MyArraylistsort ( public Enpl(String n, int sX public static void nain(String al1)0 this.nane- this.salary-s List 1ist new ArrayListcip>O: list.add(new Empl("Ram, 3000)) 1ist.add(new Empl("John".6800)) list.add(new Empl("Crish,20ee)); list.add(new Empl("Ton",2400)); Collections. sort(list,new MysalaryComp(O): System.out.printin("Sorted 1ist entries: for(Empl e:list)H public String getNane) public void setNane(String nane) ( public int getsalary) [ public void setsalary(int salary) f public String tostring)t return nane: this,name nane; System.out.printin(e): return salary; this salary salary return "Name: "this.naneSalary: "+this.salary; class MysalaryComp implenents ConparatorcEmpl>( @Override public int compare(Empl el, Empl e2) f if(e1.getsalary) e2.getsalary))( ) else f return 1 return -1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions