Java Vector sort() MethodThe sort() method of Java Vector class is used to sort the vector according to the order induced by the specified Comparator. SyntaxFollowing is the declaration of a sort() method: Parameter
ReturnThis method has return type void so, it does not return anything. ExceptionsNA Compatibility VersionJava 1.2 and above Example 1Test it NowOutput: Components of the vector: [1, 5, 2, 4, 3] Components of the vector after sorting: [1, 2, 3, 4, 5] Example 2Test it NowOutput: The vector elements are: White Green Black Orange The vector elements after sort() method are: Black Green Orange White Next TopicJava Vector |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India