• 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

What is the significance of a non-public class?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We know that classes can either be public or default/no modifier. I was wondering what is the significance of a non-public class or a default class?

Can anyone provide me with a practical example to illustrate how a default class is useful in real life?
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then the class can't be used outside of the package. It's useful for classes that only have a meaning for internal structures.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Imagine an automobile. An automobile is made up of hundreds if not thousands of parts. The parts are, in general, organized into systems -- the drive train, the ignition system, the fuel system, the electrical system. Within each system, there are a few parts that bridge between systems: for example, the spark plugs serve as a sort of connection between the electrical system and the drive train. The tires serve as a sort of connection between the drive train and the road. The steering wheel is the interface between the steering system and the driver. But there are hundreds of parts (Cotter pins, axles, struts, piston rings, bolts) which are internal to a system and are normally never exposed.

In the analogous Java program, a system becomes a package; the few special parts are the public classes; and the vast majority of behind-the-scenes parts are the non-public classes.
 
Anchit Herredia
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answers.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic