I get this object reference not set to an instance of an object error when I call constructor for CircularList.
Element:
class Element
{
public Element next;
public String data;
}
List:
class CircularList
{
public Element[] arr;
public CircularList(int n) //capacity
{
arr = new Element[n];
for (int i = 0; i < n; i++)
{
if(i==n-1) arr[i].next = arr[0];
else
arr[i].next = arr[i+1];
}
}
}