private Node<T> recremoveFirst (Node<T> list, T element)
{
if (list == null)
return null;
else if(list.next == element)
return list.next;
else{
list.next = recremoveFirst(list.next, element);
return list;
}
}//calling recursive method
public void removeFirst(T element) {
recremoveFirst(head, element);
}
int choice;
Element elem;//constructor public Element (String name, int no)
LinkedList<Element> list = new LinkedList<Element>();
String name;
int number;
case 1 : // addFirst
System.out.print("Type name and number: ");
name = Cin.readString();
number = Cin.readInt();
list.addFirst(new Element(name,number));
break;
case 2 : // addLast
System.out.println("Enter name and number to add last element: ");
name = Cin.readString();
number = Cin.readInt();
list.addLast(new Element(name, number));
break;
case 3 : // removeFirst
list.removeFirst(elem);
When I'm trying to test this recursive method it shows me an error near list.removeFirst(elem); and gives only suggestion initialize it even though it is initialized(if press initialize sets it to null). So I wonder what's is that I'm doing wrong. Error mssage: Multiple markers at this line - The local variable elem may not have been initialized - The constructor Element(Element) is undefined
if(list.elem == element)<-- are you sure about this one?