GeeCON Prague 2014*
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
Author

toUpperCase() and concat()

R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
what does this mean:
The toUpperCase() and concat() methids modifies their associated String object.
This stmt is at
http://www.jaworski.com/java/certification/
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:
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=008253
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
Sheriff

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
HIH
[ January 16, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
Thanks
 
GeeCON Prague 2014
 
subject: toUpperCase() and concat()