Methods Summary |
---|
public java.lang.Object | peek()Provides a look at the last object placed on the stack, since it
will be the first one out. This method does not change the contents
of the stack. Because this class is unsynchronized, applications
using this class are responsible for making sure that a
peek() followed by a pop() returns the
same value.
int last = size() - 1;
Object ob;
if( last == -1 ) {
return null;
}
ob = get(last);
return ob;
|
public java.lang.Object | pop()Pops the last object placed on the stack off of it and returns it.
int last = size() - 1;
Object ob;
if( last == -1 ) {
return null;
}
ob = get(last);
remove(last);
return ob;
|
public java.lang.Object | push(java.lang.Object ob)Pushes a new object onto the stack.
add(ob);
return ob;
|
public int | search(java.lang.Object ob)Searches the stack for the specified object. Returns the location
of the object with respect to the top of the stack or -1.
int i = lastIndexOf(ob);
if( i == -1 ) {
return -1;
}
else {
return (size()-i);
}
|