Object-oriented (Object Class-equals ()))

Source: Internet
Author: User

Import com. Sun. xml. Internal. ws. server. serverrtexception;

/**
* An object is a direct or indirect parent class of all objects.
* All objects are defined in this class.
* Created by rabbit on 2014-07-29. Blog garden. Liu pengcheng
*
*/
Class demo111
{

}

* Created by rabbit on 2014-07-29. Blog garden. Liu pengcheng

Public class objectdemo {
Public static void main (string [] ARGs)
{
String S1 = new string ("123 ");
String S2 = new string ("123 ");
Demo111 d1 = new demo111 ();
Demo111 D2 = new demo111 ();
D1 = d2;

System. Out. println (s1.equals (S2); // true because they all have the same 123 Value
System. Out. println (S1 = S2); // false because their memory addresses are different. Note:
// The comparison method has been rewritten.
System. Out. println (d1.equals (D2 ));
System. Out. println (d1 = d2); // both results are true because they call
// The methods in the object, equals and = are
} // The same is true for memory addresses.
}

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.