Hi All
I am trying to implement stack in
java but getting some problems
Here is the class file I wrote
And the main program invoking it
Exception in
thread "main" java.lang.NullPointerException
at mypackage.MyStackClass.push(MyStackClass.java:45) === newStack.setData(data);
at mypackage.TestStack.main(TestStack.java:10) === myStack.push(i);
I am a little confused on how to assign the element first time
For some reasons, when I wrote almost the same code in the same class file as main it works(see the code below)
Please help me so that my concepts are clear and I can proceed to implementing other data strcutures