Reputation: 33
I've tried to write this code in IntelliJ Idea, but it didn't allow me to compile.Error log: Cannot access Stack.Node. But if I compile it using windows cmd, code will be compiled. What's wrong with ItelliJ?
public class Stack {
private Node first ;
private class Node {
private String item ;
private Node next ;
}
public void push(String item) {
Node second = first ;
first.item = item ;
first.next = second ;
}
}
Upvotes: 0
Views: 4035
Reputation: 5394
I tested your code, and it just compiles without error in my version of IntelliJ (Recent version of community edition + java 8). Which version are you using ? My guess is that it's just a temporary error.
And as David Wallace mentioned, you will get a NullPointerExeption on invoking push().
Upvotes: 1