• 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!

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
To make a java class non subclassable (final class), we can use final. But any other ways to make a class final.
 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maybe making the class private too will work..
why do you need another way?
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only inner classes can be made private. Marking the class as final should suffice. The methods within the class will also be implicitly final.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"kaylan v"
Welcome to the JavaRanch! Please adjust your displayed name to match the JavaRanch Naming Policy, particularly this section: "For your publicly displayed name, use a first name, a space, and a last name."
You can change it here.
Thanks! and again welcome to the JavaRanch!
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
kalyan,
If you were to make the constructor(s) unavailable, the class would then be un-subclassable.
Instances of the class could still be obtained through some static method.
A class based on the singleton pattern, might choose to make it's contructor(s) private, and then control the any instance creation of the class through a static method (often named getInstance).
reply
    Bookmark Topic Watch Topic
  • New Topic