I am going to go out on a limb and assume this is related to your
other thread from earlier today. This is one of those instances where recursion can be your friend. I whipped up the following example using your LinkedStackClass code in your other
thread. (It's runnable but I had to slightly alter it to account for your other classes it references but which I do not have so it would compile. It no longer implements any interface and the StackUnderrunExceptions are now just plain Exception).
Notice I renamed your toString() to printStack(). Since you only get one shot at overriding toString(), is this really what you wanted to use it for?
As for how to get your toString() method to see the value of the size, well...the size variable would have to be an instance variable visible to the toString() method since you haven't declared any size variable local to the method.