Java Doc for Stack.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.util.Stack

Stack
public class Stack extends Vector (Code)
The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with five operations that allow a vector to be treated as a stack. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack is empty, and a method to search the stack for an item and discover how far it is from the top.

When a stack is first created, it contains no items.

A more complete and consistent set of LIFO stack operations is provided by the Deque interface and its implementations, which should be used in preference to this class. For example:

   
 Deque stack = new ArrayDeque();  

author:
   Jonathan Payne
version:
   1.36, 05/05/07
since:
   JDK1.0



Constructor Summary
public  Stack()
     Creates an empty Stack.

Method Summary
public  booleanempty()
     Tests if this stack is empty.
public synchronized  Epeek()
     Looks at the object at the top of this stack without removing it from the stack.
public synchronized  Epop()
     Removes the object at the top of this stack and returns that object as the value of this function.
public  Epush(E item)
     Pushes an item onto the top of this stack.
public synchronized  intsearch(Object o)
     Returns the 1-based position where an object is on this stack. If the object o occurs as an item in this stack, this method returns the distance from the top of the stack of the occurrence nearest the top of the stack; the topmost item on the stack is considered to be at distance 1.


Constructor Detail
Stack
public Stack()(Code)
Creates an empty Stack.




Method Detail
empty
public boolean empty()(Code)
Tests if this stack is empty. true if and only if this stack containsno items; false otherwise.



peek
public synchronized E peek()(Code)
Looks at the object at the top of this stack without removing it from the stack. the object at the top of this stack (the last itemof the Vector object).
exception:
  EmptyStackException - if this stack is empty.



pop
public synchronized E pop()(Code)
Removes the object at the top of this stack and returns that object as the value of this function. The object at the top of this stack (the last itemof the Vector object).
exception:
  EmptyStackException - if this stack is empty.



push
public E push(E item)(Code)
Pushes an item onto the top of this stack. This has exactly the same effect as:
 addElement(item)

Parameters:
  item - the item to be pushed onto this stack. the item argument.
See Also:   java.util.Vector.addElement



search
public synchronized int search(Object o)(Code)
Returns the 1-based position where an object is on this stack. If the object o occurs as an item in this stack, this method returns the distance from the top of the stack of the occurrence nearest the top of the stack; the topmost item on the stack is considered to be at distance 1. The equals method is used to compare o to the items in this stack.
Parameters:
  o - the desired object. the 1-based position from the top of the stack wherethe object is located; the return value -1indicates that the object is not on the stack.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.