/**
* Created by Liu pengcheng. on 2014-6-12. Blog
Usage of this
1. Used to differentiate variables with the same name (when a member variable and a local variable have the same name)
2. It is used to call each other between constructors. This statement can only be defined in the first line of the constructor to be executed before initialization.
*/
Class this_persion {
Private String name;
Private int age;
This_persion ()
{
}
This_persion (String name)
{
This. name = name;
}
This_persion (String name, int age)
{
This (name );
This. age = age;
}
Public boolean compare (this_persion p)
{
Return this. age = p. age;
}
}
Created by Liu pengcheng. on. Blog
Class this_persionDomo
{
Public static void main (String [] args)
{
This_persion p1 = new this_persion ("Zhang San", 35 );
This_persion p2 = new this_persion ("Zhang San", 35 );
Boolean B = p1.compare (p2 );
System. out. println (B );
}
}
Created by Liu pengcheng. on. Blog