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 ststic with example

1796


Java Compiler is stored in JDK, JRE or JVM?

1240


What are the two parts of a conditional statement?

724


What is the common usage of serialization? What exceptions occur during serialization?

807


What is an example of character?

790


Explain java coding standards for methods?

808


What is a java list?

821


Is it possible for yielded thread to get chance for its execution again ?

774


What is ascii format?

762


If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

813


List some features of the abstract class.

786


Can a static class have a constructor java?

730


Can we extend private class in java?

769


What is a Presistent Object?

924


Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.

798