Algorithm (4th Edition) -1.2.1 using abstract data types

Source: Internet
Author: User

Summary: This section is a review of abstract data types, including what, why, and what to do.


1. The main reasons for studying different algorithms for the same problem: their performance characteristics are Different.

2. API: describes the behavior of abstract data types by listing all constructors and instance methods (and Operations) and briefly describing their functions.

3. All data types in Java inherit the ToString () method to return a value of that type, expressed in string. Java calls the method when it uses the + operator to concatenate the value of any data type with a string Value.

You can override the ToString () method. Must be declared as public String toString () and cannot miss the previous Public.

4. Whenever a use case calls new (), the system will:

· Allocating memory space for new objects

· Call the constructor to initialize the value in the object

· Returns a reference to the object


Counter heads = new Counter ("heads");


Invoking constructors on variables and objects

To create an object with an associated declaration statement

6. Distinguish between static and non-static (instance) methods in use case code: the beginning of a static method call is the class name (which is used in uppercase), and not the beginning of a static method call is always the object name (in the custom lowercase).

7. Java passes a copy of the parameter value from the caller to the method, which is known as Pass-by-value. One important consequence of this approach is that the method cannot change the value of the Call-side variable. This strategy is exactly what we expected for the original data type (two variables are independent of each other), but we must be careful whenever we create aliases using reference types as Arguments. In other words, this convention will pass the referenced value (copy reference), that is, the reference to the object being Passed. For example, If we pass a reference to an object of type counter, The method cannot change the original reference (such as pointing it to another counter object), but it can change the value of the object, such as calling the increment () method from that Reference.


Eight original data types-------no change of original value

String---to----without changing the original value (Java string object is passed in "reference" Mode)

array, class----to Change the value of the Element/member variable

*: This must be understood!

Algorithm (4th Edition) -1.2.1 using abstract data types

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: 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.