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 toUpperCase() and  concat() 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 "toUpperCase() and  concat()" Watch "toUpperCase() and  concat()" New topic

toUpperCase() and concat()

R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
what does this mean:
The toUpperCase() and concat() methids modifies their associated String object.
This stmt is at
while explaning the ans for a que.
I looked at source code but there also both methods cretae new String and return .
so what does it mean..
I found this in archive:
hi shiva .. look I searched
it takes time but .. OK. I will do it for you ..
but here they say it is typo..
typo at two places for same reason..
I think jaworski need to updae his site OR knowledge

"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
The discussion on the link you provided gives the answer. Basically, String objects are immutable, so no methods of the String class can modify the String object on which they are invoked. If the result of the method leaves the String unchanged (for instance invoking toLowerCase on a String containing ONLY lowercase characters) then the same String object is returned otherwise a completely new String object is returned.
For instance:
String t1 = "test";
String t2 = t1.toLowercase(); // t1 and t2 reference the same object
String t3 = t1.toUpperCase(); t3 refers to a completely new String object
[ January 16, 2002: Message edited by: Valentin Crettaz ]

[Blog] [Blogroll] [My Reviews] My Linked In
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
I agree. Here's the link:
subject: toUpperCase() and concat()
It's not a secret anymore!