What and where are the stack and heap?

Programming language books explain that value types are created on the stack, and reference types are created on the heap, without explaining what these two things are. I haven’t read a clear explanation of this. I understand what a stack is. But, Where and what are they (physically in a real computer’s memory)? To what … Read more

Printing the stack values in Java

In Java, I want to print the contents of a Stack. The toString() method prints them encased in square brackets delimited by commas: [foo, bar, baz]. How do I get rid of them and print the variables only? My code so far: Stack myStack = new Stack (); for(int j=0; j<arrayForVar.length; j++) { if(arrayForVar[j][1] != … Read more