• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

final classes vs immutable classes??

 
Ranch Hand
Posts: 74
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers!

I have a bit doubt in the case of final and immutable classes in java, please explain the concepts with example .
is it both having same meaning ??
awaiting for genuine reply......

Thanks..
Vivek
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here you go !
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a class is final, it just means that you cannot subclass it. Immutable means that you cannot change the state of an object after it has been created. Making classes immutable has many advantages, see this article for more details.

When you want to make a class immutable, you should make it final. But just making it final does not by itself make the class immutable.
 
viki Bhardwaj
Ranch Hand
Posts: 74
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:When a class is final, it just means that you cannot subclass it. Immutable means that you cannot change the state of an object after it has been created. see this article for more details.



yes! this is pretty enough to clear my doubt...
Thanks ... Jesper!
 
reply
    Bookmark Topic Watch Topic
  • New Topic