PlayJava Day006

Today Plant Science:

/ * 2019.08.19 started to learn, to make this shift. * /

Constructor does not return value (i.e., return empty).

this: reference instance (object).

JVM: ①static method area: static data memory

     ② stack area: references

     ③ heap: an object / object memory address ----> new class name ();

public > protected > package(default) > private

Encapsulation ----> Access Control permission

When private to modify, get / set methods can provide an interface to access private.

Such as:

private int a ;
get方法:public int getA () {
            return a ;
        }
set方法:public void setA (int a) {
            this.a = a ;
        }
取用:Demo demo = new Demo () ;
         demo.setA(2) ;
         int a = demo.getA() ;
     System.out.println(a) ;

First sentence: package: Package Definition

   import: import Class

Internal class: class defined inside the class.

Internal class advantages: can easily use the external attributes of the class.

Internal class disadvantages: breaking the ring type basic structure, and therefore be used with caution.

= Outer Outer new new Outer ();   // instantiate external object 
. Outer.Inner = Inner Outer new new Inner ();   // instantiate inner class object

Block:

① Normal code block: i.e. enclosed in {}.

Building blocks ②: before performing constructor, each performing a constructor is executed once. That is complementary to the constructor. Written directly in the class.

③ static block of code: static {} (Note: no semicolon) is executed first, and is performed only once.

Anonymous objects / classes: new class name ();

Shift lines (one or more lines) Shortcut: alt + down direction keys

 

Guess you like

Origin www.cnblogs.com/JavaDemo01/p/11489266.html