Trying to use StackLL method size() is returning a null pointer error. I cannot figure out why this is, as count is initialized to 0. My only guess is that I am not properly creating an instance of LinkedList.java. However, I have no idea what I should do to correct this. Any help would be greatly appreciated.
The following code is a portion of a linked list implementation for a 1st year assignment, I have stripped out a lot of the code to focus on the problem areas. I cannot change LinkedList.java.
StackLL.java
public class StackLL implements Stack
{
// The linked list that will contain the values in the stack
private LinkedList values;
public int size()
{
return values.size();
}
}
LinkedList.java
public class LinkedList
{
Node head;
int count;
public LinkedList ()
{
head = null;
count = 0;
}
public int size ()
{
return count;
}
}
private class Node
{
int value;
Node next;
Node()
{
}
Node (int value)
{
this.value = value;
}
}