Two-dimensional arrays
Defined:
Format 1 int[][] arr = new int[3][2];
Format 2 int[][] arr = new int[3][];//null per one-dimensional array initialization
Null pointer exception
Format 3 int[][] arr ={{},{},{}};
Application Scenarios
Array of arrays
Map Collection
Object oriented
Class-to-object relationships
Class: The description of a thing
Objects: Instances of classes
Properties and Behavior
Defining a class is the member in the definition class
Member Variables <--> properties
member functions <--> Behaviors
Memory representation of the object
Stack main Function object variable
Heap Creation Object instance
The difference between a member variable and a local variable
1. Member variables are defined in the class and can be accessed throughout the class
A local variable is defined in a function, statement, local code block, only valid in the owning area
2. member variables exist in the object of heap memory
Local variables exist in the method of stack memory
3. Different life cycle
4, the member variable has the default initialization value, the local variable does not have
The member variable has the same name as a local variable
Method into the Stack
Anonymous objects
New Car ();
1. Methods are called only once, simplifying to anonymous objects
2, as the actual parameters to pass
Parameter passing is the basic data type
1 classdemo{2 Public Static voidMain (string[] args) {3 intX=3;4 Show (x);5System.out.println ("x=" +x);6 }7 Public Static voidShowintx) {8X=4;9 }Ten}
Parameter passing is a reference data type
1 classdemo{2 Static intX=3;3 Public Static voidMain (string[] args) {4Demo d =NewDemo ();5 Show (d);6System.out.println ("x=" +x);7 8 }9 Public Static voidShow (Demo d) {TenD.x=9; One } A}
Encapsulates the properties and implementation details of hidden objects, providing public access to the outside
Private is visible to this class
Java Day 06