package com.day.dreamer.queue;publicclassDemo04{publicstaticvoidmain(String[] args){
Person person =newPerson().increment().increment().increment();
System.out.println(person.getNumber());}}classPerson{privateint number =0;publicintgetNumber(){return number;}publicvoidmethod01(){/*1. 如果调用当前类的其他成员方法,其他成员变量,this可以省略*/this.method02();}publicvoidmethod02(){}/*2. 只有当明确的要返回当前对象的时候,才会使用this
* 可以通过链式编程的方法来写改程序*/public Person increment(){
number++;returnthis;}/*3. 将当前对象传递给其他的方法的参数*/publicvoidwork(){work01(this);}publicvoidwork01(Person person){}}
classStudent{/*静态成员变量和静态代码块,从上倒下,依次加载*/privatestatic Girl first =newGirl("first");static{
Girl second =newGirl("second");}privatestatic Girl second =newGirl("third");}classGirl{publicGirl(String name){
System.out.println("girl is coming: "+ name);}}