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 must a class do to implement an interface in java programming?

531


Can we have any code between try and catch blocks?

553


What is the type of lambda expression?

534


What programs use java?

466


Difference between serialization and deserialization in java?

648






What is polymorphism and what are the types of it?

494


Is assembly language a low level language?

491


What are the drawbacks of reflection?

556


Tell me a few examples of final classes defined in Java API?

557


What is the purpose of lambda expressions?

580


how can you take care of mutual exclusion using java threads? : Java thread

605


Is java map thread safe?

485


What are aggregate functions explain with examples?

517


What is javac_g?

586


What is private static class in java?

507