Use a consumer list to simulate the Stack Function

Source: Internet
Author: User

Collection systems are important in Java. The entire Collection system emerged after JDK. As the top layer of the entire system, Collection has the general functions of the entire system. For the younger brother, there are also their own merits. Next, let's take a look at the features of the shortlist and Stack.
Requirement: Use the consumer list to simulate the Stack function.
Analysis: First, you need to understand the intention of the question. The question is not difficult, but it is not easy to understand the question. This question requires that you define a set to simulate the functions of the Stack class. Then again, what are the characteristics of Stack? This requires an understanding of the Stack class. The Stack is a Stack, and its features are post-release. Its methods include Stack pressure, Stack play, and empty judgment. Once you know this, it is just a matter of course to do this. Next let's take a look at the code.

StackEnum <String> se = StackEnum <> se. push ("Hello" se. push ("Java" se. push ("World "(! String string = StackEnum <E> shortlist = shortlist <E> shortlist. addFirst (e); e; returns list. removeFirst (); inclulist. size () = 0 ;}

Once again, we can see the application of generics in Java, so knowledge needs to be accumulated. without the support of generics, we can only write specific types here.

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.