top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

I would like to the list to be sorted on the basis of the employeeID of Employee class. How can I do it?

+1 vote
457 views

If an Employee class is present and its objects are added in an arrayList.

posted Sep 22, 2013 by Vivek Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
please avoid your homework question

2 Answers

+2 votes

1.Implement Comparable interface for the Employee class and override the compareTo(Object obj) method in which compare the employeeID of person
2.Then call Collections.sort() method and pass that list as an argument.

Now consider that Employee class is a jar file.
1.Since Comparable interface cannot be implemented, create Comparator and override the compare(Object obj, Object obj1) method .
2.Call Collections.sort() on the list and pass comparator as an argument

answer Sep 23, 2013 by Arvind Singh
+1 vote

Treeset will be a better DS to use for this usecase.

answer Oct 1, 2013 by Vikalp Kumar
Similar Questions
+3 votes

How does MME make out which tracking area is neighbor of which one ?

+1 vote

I would like to know the behavior of GGSN when it receives ASR(Abort-Session-Request) from OCS(Online Charging System).

As I have gone through the RFC 3588, it was not explicitly stated that GGSN should report the usage of existing services(classified based on Rating-Group/Service-Identifier).

Could some explain here what is the expected behavior from GGSN?

Will GGSN come back to OCS with CCR-T with USU for all the existing services? Please shed some lights on this topic.

Can the below behavior be expected from GGSN? Appreciate your response on this topic.

...