Object behavior and array, object behavior Array
1.Debugging steps:
A. Locate the logical error point and set the breakpoint
B. Start debugging-Debug
C. One-step execution (F5 step-by-step, F6 skip), observe the variable (variables)
D. Modify
2.Call Method
A. the method returns A value.
B. The method does not return a value.
C. The method throws an exception to the method caller.
3.Component of method Signature
A. access modifier (public, private, protected, and default)
B. Optional modifier (static, final, abstract, native, synchronized mutually exclusive)
C. Return Value
D. Method Name
E. List of formal parameters
F. List of thrown exceptions
4.In Java, only values are passed.
5.Method overload
Meaning: in the same class, one or more methods have the same name, but the parameter list is different (different parameter types or different number of parameters meet one of the conditions)
6.Constructor (constructor)
A. constructor is called when the class creates an object to initialize the member variables in the object.
B. the constructor must meet two conditions:
A. the constructor name must be the same as the class name.
B. the constructor does not return values or return value types
C. When no constructor is added to the class, the compiler adds a default constructor to the class. The default constructor has no formal parameters and does nothing. If one or more constructors are added to the class, the compiler will not add the default constructor to the class.
D. use this: this (parameter list) in the constructor to call other constructor in this class. However, this statement must be the first line of the constructor, otherwise, an error is reported.
7.Array meaning:
An array is a set of elements stored in a continuous memory block. Each element in the array must be of the same data type and be distinguished by an index (subscript. The index of the first element in the array is 0. (Index: number of elements in the array)
8.To create an array:
A. Declare A reference to the array. For example: int [] sum; or int sum [];
B. Use the keyword new to allocate space. For example, sum = new int [20] Or int [] sum = new int [10];
9.Array length: length
Array subscript out-of-bounds error:
Java. lang. ArrayIndexOutOfBoundsException;
10.Array Initialization
Int [] sum = {1, 4, 5, 6, 7 };
Int [] sum = new int };
11.ForeachSyntax structure: foreach is used for array or set traversal.
For (data type variable: array or set name ){
}
Data Type: Type of a single element
Variable: the element value that is traversed.
12.Multi-dimensional array
Int [1] [2] sum = {
{1, 2, 3 },
{4, 5, 6}
};
For (data type variable: array or set name ){
For (data type variable: array or set name ){
}
}