File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String Output related. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String Output related." Watch "String Output related." New topic

String Output related.

Pinki Roy

Joined: May 16, 2008
Posts: 22

I do not understand why this is giving the output of False. Please explain.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 10033

This is a good chance for you to explore a little bit and understand the ideas behind reference equality, object equality and perhaps String immutability.

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Rahul Shinde

Joined: Jan 29, 2002
Posts: 11
The String class is immutable, once it is created a String object cannot be changed.

You might want to do .equals() instead to check for contents. i.e.
I agree. Here's the link:
subject: String Output related.
It's not a secret anymore!