class Solutions { public static void main(String[] args){ String s = "Hello"; String s1; s1 = s.substring(0,0); System.out.println("="+s1); s1 = s.substring(0,1); System.out.println("="+s1); s1 = s.substring(2,2); System.out.println("="+s1); s1 = s.substring(4,5); System.out.println("="+s1); //System.out.println( s.startsWith(null) ); System.out.println( s.startsWith("") ); System.out.println( s.startsWith("e") ); System.out.println( s.startsWith("H") ); System.out.println( s.startsWith("Hello") ); System.out.println( s.startsWith("Hello World") ); System.out.println("---"); //System.out.println( startsWith(s,null) ); System.out.println( startsWith(s,"") ); System.out.println( startsWith(s,"e") ); System.out.println( startsWith(s,"H") ); System.out.println( startsWith(s,"Hello") ); System.out.println( startsWith(s,"Hello World") ); printWords("You #!@ Miserable earthworms! Numbskulls! and Carpet-sellers!"); WordIterator wi = new WordIterator("You #!@ Miserable earthworms! Numbskulls! and Carpet-sellers!"); while (wi.hasMore()) System.out.println(wi.next()); } public static boolean startsWith(String s, String prefix) { if(prefix == null) throw new NullPointerException(); if (prefix.length()>s.length()) return false; for(int i = 0; i 0; } public String peek(){ return word; } public String next(){ String result = peek(); moveToLetter(); getWord(); return result; } }