HOW IS EQUALS() IN STRING CLASS IMPLEMENTED

  1. The method first checks if s1==s2.  If it is then it return true. Recall this only be true if the string objects are interned. Else though the value of the objects are same == will always return false for String object
  2. If s1== s2 returns false then length of the both the String is checked if they are same
  3. If same then comparison is done on each character of both objects sequentially.
  4. Returns true if all characters are same.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Cheat Sheet To JAVA Latest Technology

%d bloggers like this: