Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

equalsIgnoreCase

801912Apr 8 2007 — edited Apr 8 2007
I need to use equalsIgnoreCase to see if a string value matches the word "Yes" or not.
and I'm also asked about which one of the following ways I would choose, and why.
str = obj.getValue();
1) "Yes".equalsIgnoreCase(str);

2) str.equalsIgnoreCase("Yes");
I know that they both work the same way; that is, they provide same results and both ways are frequently used. But I can't seem to find which one is a better one to use, after I've looked at the implementation of equalsIgnoreCase(String str) in String.java.

Could someone please explain this to me?
Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2007
Added on Apr 8 2007
5 comments
232 views