Java Day 06

Source: Internet
Author: User

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

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.