Summary: This section is a review of abstract data types, including what, why, and what to do.
Focus:
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
5.
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.
Summary:
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