The Artima Developer Community
Sponsored Link

Java Buzz Forum
Ye Olde == vs. Equals, with Strings

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Michael Cote

Posts: 10306
Nickname: bushwald
Registered: May, 2003

Cote is a programmer in Austin, Texas.
Ye Olde == vs. Equals, with Strings Posted: May 28, 2004 12:27 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Michael Cote.
Original Post: Ye Olde == vs. Equals, with Strings
Feed Title: Cote's Weblog: Coding, Austin, etc.
Feed URL: https://cote.io/feed/
Feed Description: Using Java to get to the ideal state.
Latest Java Buzz Posts
Latest Java Buzz Posts by Michael Cote
Latest Posts From Cote's Weblog: Coding, Austin, etc.

Advertisement
In this tip you saw that the only safe way to test that Strings have the same value is with the equals() method. If you work with Strings that have the same value, then it might be worth interning them into the constants pool. That way you can make a quicker check using the == operator. In any case, you can see that you have to be careful before deciding to use == to check equivalence.

This months Sun's Java-spam (or whatever it's called) has an article on == and .equals for String. Here's a tip: if you're going to be interviewing for a job, read this and understand it.

Read: Ye Olde == vs. Equals, with Strings

Topic: More on BPEL and Formalism Previous Topic   Next Topic Topic: BEA going Open Source

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use