package Recursion; import java.util.*; public class LListRecursiveSearch { private static final String colors[] = { "black", "yellow", "green", "blue", "violet", "silver" }; public LListRecursiveSearch(){ LinkedList llist = new LinkedList(); for ( int count = 0; count < colors.length; count++ ) llist.add( colors[ count ] ); if(search("green", llist))//explain in details System.out.println("green is found in the list"); else System.out.println("green is not found in the list"); if(search("magenta", llist))//explain in details System.out.println("magenta is found in the list"); else System.out.println("magenta is not found in the list"); } public boolean search(String str, LinkedList restOfList){ if(restOfList.size()==0) return false; else if(restOfList.remove().equals(str)) return true; else return search(str, restOfList); } public static void main( String args[] ) { new LListRecursiveSearch(); } } // end class LListRecursiveSearch