java single link list class LinkList1 { public Link head; public LinkList1(){ head=null; } public void insertfirst(int data){ Link newLink= new Link(data, head); head=newLink; } public Link search (int key){ if (head=null); System.out.println("empty list"); return null; Link current=head; while (current.getData!=key) { if (current.next==null) return null; else current=current.next;
What problem are you having?
if (head=null); A single equal sign is for assignment, comparison uses a double equal sign. If statements don't have a semi-colon. More than one line in an if stanza should have braces around them.
Join our real-time social learning platform and learn together with your friends!