Algorithm (4th Edition) -1.3.1 API

Source: Internet
Author: User
Tags arithmetic

Summary: This section describes the classic example of generics, auto-boxing, iteration, Bag, Queue, stack, and a stack use case-evaluation of arithmetic expressions.

Focus:

1. A key feature of the abstract data types of collection classes is that we should be able to use them to store any type of Data. A special Java mechanism is able to do this, known as generics, also called parameterized Types.

2. When working with assignment statements, method arguments, and arithmetic or logical expressions, Java is automatically referenced in the reference type (Character, Integer ...). ) and the corresponding raw data type (char, int ... ) and convert between Them.

Auto Boxing: Int--Integer

Auto-unpacking: Integer--int

3. If the collection is iterative, the use case can print a list of transactions with a single line of statements:

 for (Transaction t:collection) {    stdout.println (t);}

This syntax is called a foreach statement: you can treat the for statement as a per-trade T (foreach) in the collection, executing the following code Snippet.

It's hard to imagine a clearer and more concise code than This.

4. A backpack is a collection data type that does not support removing elements from it-its purpose is to help the use case to collect elements and iterate through all the collected elements (use cases can also check whether the backpack is empty or get the number of elements in the backpack).

Using bag can indicate that the order in which elements are processed is Unimportant.

5. A classic reason to use a stack iterator in an application is to reverse their relative order while preserving the elements with the Collection.

6. Evaluation algorithm of double stack arithmetic expression of Dijkstra

Cow!

Algorithm (4th Edition) -1.3.1 API

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.