Java Collections reverse() Method21 Mar 2025 | 1 min read The reverse() method of Java Collections class is used to reverse the order of the elements in the specified list. SyntaxFollowing is the declaration of reverse() method: Parameter
ReturnsThe reverse() method does not return anything. ExceptionsNA Compatibility VersionJava 1.2 and above Example 1Output: Original List:- [Java, PHP, Python, COBOL] Modified List:- [COBOL, Python, PHP, Java] Example 2Output: Original List:- [1, 2, 3, 4] Modified List:- [4, 3, 2, 1] Example 3Output: Original Array : [10, -20, 30, -40, 50] Modified Array : [50, -40, 30, -20, 10] Next TopicJava Collections Class |
Java Collections Method The method of Java Collections class is used to get an unmodifiable view of the specified navigable set. Syntax Following is the declaration of method: public static <T> NavigableSet<T> unmodifiableNavigableSet(NavigableSet<T> s) Parameter Parameter Description Required/Optional s It is the navigable set for which an unmodifiable view is to be...
2 min read
Java Collections Method The method of Java Collections class is used to get a synchronized (thread-safe) map backed by the specified map. Syntax Following is the declaration of method: public static <K,V> Map<K,V> synchronizedMap(Map<K,V> m) Parameter Parameter Description Required/Optional m It is the map which will be wrapped in a synchronized map. Required Returns The...
2 min read
Java Collections Method The method of Java Collections class returns an empty sorted map which is immutable. Syntax Following is the declaration of method: public static final <K,V> SortedMap<K,V> Parameter This method does not accept any parameter. Returns The method returns an empty immutable Sorted Map. Exceptions NA Compatibility Version Java 1.8...
1 min read
Java Collections. Method The method of Java Collections class is used to get the Set that has no elements. These empty Set are immutable in nature. Syntax Following is the declaration of method: public static final <T> Set<T> Parameter This method does not accept any parameter. Returns The ...
5 min read
Java Collections Method The method of Java Collections class is used to get a synchronized (thread-safe) sorted set backed by the specified sorted set. Syntax Following is the declaration of method: public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> s) Parameter Parameter Description Required/Optional s It is the sorted set which will be wrapped in...
3 min read
Java Collections Method The is a Java Collections class method which returns a comparator that imposes the reverse of the natural ordering on the objects. There is two different types of Java method which can be differentiated depending on its parameter. These are: Java...
3 min read
Java Collections Method The method of Java Collections class is used to get an enumeration that has no elements. Syntax Following is the declaration of method: public static <T> Enumeration<T> Parameter This method does not accept any parameter. Returns The method returns an empty enumeration. Exceptions NA Compatibility Version Java 1.7...
2 min read
Java Collections Method The method of Java Collections class is used to replace all occurrences of one specified value in a list with the other specified value. Syntax Following is the declaration of method: public static <T> boolean replaceAll(List<T> list, T oldVal, T newVal) Parameter Parameter Description Required/Optional list It...
2 min read
Java Collections Method The method of Java Collections class is used to get an immutable set which contains only the specified object. Syntax Following is the declaration of method: public static <T> Set<T> singleton(T o) Parameter Parameter Description Required/Optional o It is the object which will be stored in the returned set. Required Returns The...
2 min read
Java Collections Method The is a method of Java Collections class which adds all of the specified elements to the specified collection. The elements to be added may be specified individually or as an array. Syntax Following is the declaration of method: public static <T> boolean...
2 min read
We request you to subscribe our newsletter for upcoming updates.
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