import java.util.*; public class Story{ public static void main(String[] args ){ LinkedList list = Story.getTextAsLinkedList(); Iterator i = list.iterator(); while( i.hasNext() ){ System.out.println( i.next() ); } Iterator i2 = list.iterator(); while( i2.hasNext() ){ String word = (String)i2.next(); if(word.length()>6) System.out.println(word); } System.out.println(list.get(45)); } public static LinkedList getTextAsLinkedList(){ String s= "`This must be the wood, she said thoughtfully to herself, `where things have" +" no names. I wonder what'll become of MY name when I go in? I shouldn't like to lose" +" it at all -- because they'd have to give me another, and it would be almost certain" +" to be an ugly one. But then the fun would be, trying to find the creature that had" +" got my old name! That's just like the advertisements, you know, when people lose dogs" +" -- ANSWERS TO THE NAME OF `DASH:' HAD ON A BRASS COLLAR -- just fancy calling" +" everything you met 'Alice,' till one of them answered! Only they wouldn't answer at" +" all, if they were wise.' She was rambling on in this way when she reached the wood:" +" it looked very cool and shady. `Well, at any rate it's a great comfort,' she said as" +" she stepped under the trees, `after being so hot, to get into the -- into WHAT?' she" +" went on, rather surprised at not being able to think of the word. `I mean to get" +" under the -- under the -- under THIS, you know!' putting her hand on the trunk of" +" the tree. `What DOES it call itself, I wonder? I do believe it's got no name -- why," +" to be sure it hasn't!'. She stood silent for a minute, thinking: then she suddenly" +" began again. `Then it really HAS happened, after all! And how, who am I? I WILL" +" remember, if I can! I'm determined to do it!' But being determined didn't help much," +" and all she could say, after a great deal of puzzling, was,`L, I KNOW it begins with" +" L!'"; StringTokenizer st = new StringTokenizer( s, " .,-`:!?", false ); LinkedList list = new LinkedList(); String current; while( st.hasMoreTokens() ){ current = st.nextToken(); if( ! current.equals( " " ) ){ list.add( current.toLowerCase() ); } } return list; } }