• Post Reply Bookmark Topic Watch Topic
  • New Topic

testing String as immutable  RSS feed

 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mean ??
 
WiLL Tao
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!