Simulate the set of stack data structures with the consumer list and test it. The consumer List Data Structure

Source: Internet
Author: User

Simulate the set of stack data structures with the consumer list and test it. The consumer List Data Structure

1/* 2 * requirement: use consumer list to simulate a set of stack data structures, and Test 3 * create a class to encapsulate the Linked method 4 */5 public class demo4_shortlist {6 public static void main (String [] args) {7 Stack stack = new Stack (); 8 stack. in ("a"); 9 stack. in ("B"); 10 stack. in ("c"); 11 stack. in ("d"); 12 while (! Stack. isEmpty () {13 System. out. println (stack. out (); 14} 15} 16}
1 import java. util. shortlist; 2 3 public class Stack {4 @ SuppressWarnings ("rawtypes") 5 private shortlist list = new shortlist (); 6 7 @ SuppressWarnings ("unchecked ") 8 public void in (Object obj) {// simulate stack 9 list. addLast (obj); 10} 11 12 public Object out () {// simulate stack 13 return list. removeLast (); 14} 15 16 public boolean isEmpty () {// judge whether it is empty 17 return list. isEmpty (); 18}

 

Related Article

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.