public class WhileDemo { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String t = "ab78%f^fhj*k"; System.out.println(getLetters(t)); } public static String getLetters(String s){ int j = 0; int len = s.length(); String letters = ""; // this double while loop illustrates the difference // between && and &, but the simpler code that we wrote // on the blackboard using only one while loop was better while (j < len){ // skip over non-letters while (j < len & (s.charAt(j) < 'a' || s.charAt(j) > 'z')){ j++; } if(j < len){ //concatenate new letter onto ones already obtained letters = letters + s.charAt(j); } j++; } return letters; } }