It's showing some kind to error at head "Cannot resolve symbol 'head' ".
import java.util.LinkedList;
public class reversellusingiteration {
static Node head;
static class Node{
int data;
Node next;
Node(int d) {
this.data = d;
this.next = null;
}
}
Node reverse(Node node){
Node curr=node;
Node prev=null;
while(curr!=null){
Node temp=curr.next;
curr.next=prev;
prev=curr;
curr=temp;
}
return prev;
}
public static void main(String[] args) {
LinkedList list=new LinkedList();
list.head =new Node(90); //here is the problem
list.head.next=new Node(78);
}
}
Please someone help me with this