This Java tip illustrates a method of implementing a Stack. Developer may use stack for storing elements in a memory. Stack uses First in Last out (FILO). Developer may need to use push and pop to insert and retrieve data elements from the stack.
LinkedList stack = new LinkedList(); // Push on top of stack stack.addFirst(object); // Pop off top of stack Object o = stack.getFirst(); // In case multiple threads are using a stack // there is a need to synchronize methods stack = (LinkedList)Collections.synchronizedList(stack);