aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes testing String as immutable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "testing String as immutable" Watch "testing String as immutable" New topic
Author

testing String as immutable

Mike Cunningham
Ranch Hand

Joined: Nov 14, 2000
Posts: 129
Is there a way to test that a String is immutable by attempting to change the actual string object in the constant pool?
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
mean ??


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
WiLL Tao
Ranch Hand

Joined: Dec 14, 2001
Posts: 56
Is this code ok?
because "==" is shallow compare,so if string is mutable, the refence address will not be changed.
but this code provdes m1 create new ojbect.


Thank Folks who <b>Make Sense</b> here.<br />SCJP Platform 2
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: testing String as immutable