@@ -0,0 +1,1649 @@
+/*%0AA stack is a data structure that allows data to be inserted (a 'push' operation), and removed (a 'pop' operation). Many stacks also support a read ahead (a 'peek' operation), which reads data without removing it. A stack is a LIFO-queue, meaning that the last data to be inserted will be the first data to be removed.%0A%0AWhen we insert data into a stack, it is placed at the head of a queue. This means that when we remove data, it will be in reverse order. Adding 1,2,3,4 will return 4,3,2,1. Stacks aren't the most frequently used data structure, but they are extremely useful for certain tasks.%0A%0AJava provides a stack implementation, in the form of java.util.Stack. Stack's are a subclass of java.util.Vector, and share some similarities. A Vector, after all, is a queue, and a Stack is an ordered LIFO queue.%0A%0AStacks are quite easy to use. Here's a sample application that uses a stack to reverse a list of numbers.%0A*/%0Aimport java.util.Stack;%0A%0Apublic class StackDemo%0A%7B%0A        public static void main(String args%5B%5D)%0A        %7B%0A                // Create a new, empty stack%0A                Stack lifo = new Stack();%0A%0A                // Let's add some items to it%0A                for (int i = 1; i %3C= 10; i++)%0A                %7B%0A                        lifo.push ( new Integer(i) );%0A                %7D%0A%0A                // Last in first out means reverse order%0A                while ( !lifo.empty() )%0A                %7B%0A                        System.out.print ( lifo.pop() );%0A                        System.out.print ( ',' );%0A                %7D%0A%0A                // Empty, let's lift off!%0A                System.out.println (%22 LIFT-OFF!%22);%0A        %7D%0A%0A%7D%0A

Create stacksjava.java