How to sort a vector elements that contains the user define
class object? (Note: If Suppose consider, A Student class
contain two data members. They are String studentName and
int rollNo. I am creating Four objects for this class, each
object contains students details like name and roll no. Now
i am storing that objects in vector and if i retiving the
elements from the vector means then it should be display in
sorting order)

Answer Posted / kalyan g

other way to achieve this is implementing comparator
interface and implement compare(object) method.

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by design patterns?

814


What is keyword and identifier?

891


What is the purpose of java?

777


What is the difference between stored procedure & function?

767


What is Session reduplication and how its done?

1789


Where is stringbuffer stored?

769


Is there any sort function in java?

858


What is the applet security manager, and what does it provide?

778


Why there are some null interface in JAVA? What does it mean? Give some null interface in JAVA?

873


What is args length in java?

945


String class is defined under which package in java?

829


What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?

2222


How many unicode characters are there?

806


Can we override the overloaded method?

817


Does treeset use compareto?

755