reverse string list java code example
Example 1: how to reverse a list in java
List<String> stringList = Arrays.asList("A", "B", "C");
Collections.reverse(stringList);
assertThat(stringList).containsExactly("C", "B", "A");
Example 2: Collections reverse on java
Collectons.reverse(list);
Example 3: reverse string java
String string="whatever";
String reverse = new StringBuffer(string).reverse().toString();
System.out.println(reverse);
Example 4: reverse a string in java
As we know that String is immutable. String class do not have reverse() method.