public class temp {
public class Node {
int data;
Node next;
Node(int data1, Node next1) {
this.data = data1;
this.next = next1;
}
Node(int data1) {
this.data = data1;
this.next = null;
}
}
public static void main (String args[]) {
int arr[] = {2,4,6,8};
Node y = new Node(arr[3]);
System.out.println(y.data);
}
}
error: non-static variable this cannot be referenced from a static context
Node y = new Node(arr[3]);
^
created instance of class Node still showing error
New contributor
Flash Soul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.