|
![]() |
|
![]() |
|
![]() |
String
methods, check Java String Methods Reference.
|
|
public class StringReverse { public static void main( String[ ] args ) { int strLength = args[0].length( ); // StringBuilder is used to create a modifiable string. StringBuilder sb = new StringBuilder( strLength ); for ( int i = strLength - 1; i >= 0; i-- ) // Append the characters one by one to StringBuilder. sb.append( args[0].( i ) ); // Returns the value of a String object. String reverseString = sb.( ); System.out.println( args[0] + " ⇒ (reverse) ⇒ " + reverseString ); } } |
|
|
|
“It is amazing how complete is the delusion that beauty is goodness.” ― Leo Tolstoy, The Kreutzer Sonata |