• Post Reply Bookmark Topic Watch Topic
  • New Topic

String Class  RSS feed

 
Kush Kush
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why String & StringBuffer classes are declared as Final ?
 
Stefan Krompass
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
there are two reasons:
1. Performance
2. Security: Many classes rely on the immutability of the String-class. If String was not final, the immutability could be undermined by a subclass of String.
cu
Stefan
 
Kush Kush
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Stefan but what do you mean by Performance ? Making a class final increases its performance ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!