Java Stack access stack

Source: Internet
Author: User

    /**     *  @param  args      */     @SuppressWarnings ({  "rawtypes",  "Unchecked" &NBSP;}) public static  void main (String[] args)  {        Stack  Stack = new stack (); //  Creating a Stack object           System.out.println ("11111, absdder, 29999.3  three elements into the stack");          stack.push (New integer (11111))  //into   stack   pressing integers  11111         printstack (stack);   //display all elements in the stack          stack.push ("Absdder");  //  Stack   Press          Printstack (stack);   //displays all elements in the stack         stack.push (new  Double (29999.3));  //to   stackMedium   Press into         printstack (stack),   //display all elements in the stack          string s = new string ("Absdder");         system.out.println ("element Absdder in the stack's position" +stack.search (s));               system.out.println ("element 11111 in the stack's position" +stack.search ( 11111));         system.out.println ("11111, absdder, 29999.3   Three elements out of the stack ");  //popup   Stack top element          system.out.println (" Element "+stack.pop () +" out stack ");         printstack (stack);   // Displays all elements in the stack         system.out.println ("element" +stack.pop () + "Out stack");         printstack (stack);   //display all elements in the stack          system.out.println ("element" +stack.pop () + "out stack");         printstack (stack);   / /display all elements in the stack      }     @SuppressWarnings ("Rawtypes") private  Static void printstack (stack<integer> stack ) {         if  (Stack.empty ())              System.out.println ("Stack is empty, no element");             else  {                 System.out.print ("Elements in the Stack:");                 enumeration items = stack.elements (); //  Gets the enumeration object in  stack                   while   (Items.hasmoreelements ()) &NBSP;//Display Enumeration (stack )   all elements in                      system.out.print (items.nextelement () + " ");             }         System.out.println ();  //line     }

This article is from the "Listen to the Rain Hope Eternal" blog, please be sure to keep this source http://yongguang.blog.51cto.com/9153118/1709639

Java Stack access stack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.