How to reverse a String in java?
Input: javaonjavaOutput: avajnoavaj
Well there are some complex approaches to it. Storing the String as character array and then reverse the character array. Convert it back to String.
But since Java is Java. We have all the support available.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.out.println(new StringBuilder("javaonjava").reverse().toString()); | |
//avajnoavaj |
No comments:
Post a Comment