The answer follows.
class Tester { public boolean test( String trial ) { String lower = trial.toLowerCase(); StringBuffer azBuffer = new StringBuffer(); for ( int j=0; j < lower.length(); j++ ) { char c = lower.charAt(j); if ( c >= 'a' && c <= 'z' ) azBuffer.append( c ); } String forward = azBuffer.__________________; String backward = azBuffer.___________ . ___________ ; . . . . } } public class PalindromeTester { . . . . . }
After the for
loop,
azBuffer
contains the lower case alphabetic characters from the
String in their original order.
Next the method should:
String
based on azBuffer
azBuffer
.String
based on the reversed azBuffer
This can be done in two statements, using methods of StringBuffer
.