PPT Slide
A “Stack” is a class found in the package
java.util. We create an instance of the class
Stack using the keyword new thus:
java.util.Stack x = new Stack();
It’s difficult to come up with a simple example of an object. One might use java.lang.String; however, there are some exceptions to String creation built into Java. One could also use the java.lang.Integer class; however, this presumes some knowledge of wrapper classes.
Note also that I’ve called the Stack in this example “c”, instead of “myStack” or something similar. It’s very common to use the ‘my-’ prefix in object creation; however, those not used to OO language might find it confusing. To emphasize that the Stack instance is merely an object, we use the familiar variable ‘c’. Of course, we could have called the Stack “foo”.
This differs from procedural (e.g., C) and functional languages (e.g., Lisp) where other data structures would be used to model the Stack. More on classes in later slides . . .