// Fig. 30.2: StringMiscellaneous.java // This application demonstrates the length, charAt and getChars // methods of the String class. public class StringReverse { public static void main( String args[] ) { String s1 = "hello there"; System.out.printf( "s1: %s", s1 ); // test length method System.out.printf( "\nLength of s1: %d", s1.length() ); // loop through characters in s1 with charAt and display reversed System.out.print( "\nThe string reversed is: " ); for ( int count = s1.length() - 1; count >= 0; count-- ) System.out.printf( "%s ", s1.charAt( count ) ); } // end main }