Package top.hyself; Public class F$demo { publicstaticvoid main (string[] args) { // TODO auto-generated method stub new F$demo (). Fun (); } Private void Fun () { System.out.println ("Hello world!!!" ); }}
Packagetop.hyself; Public classF$demo {String name;intAge ; PublicF$demo (String name,intAge ) { This. Name =name; This. Age =Age ; } Public BooleanCompare (F$demo per) {if( This==per) { return true; } if( This. Name.equals (Per.name) && This. Age = =per.age) {return true; }Else { return false; } } PublicString GetName () {return This. Name; } Public intGetage () {return This. Age; } Public Static voidMain (string[] args) {//TODO auto-generated Method StubF$demo Per1 =NewF$demo ("Cousins", 26); F$demo Per2=NewF$demo ("Cousins", 26); if(Per1.compare (Per2)) {System.out.println ("is the same person!" "); } }}
Java 2017.11.06 Yang Haoning jobs (2)