Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Default for Class is Public?

 
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a package with several different class files e.g. Name, AddressList, PhoneList, EmailList etc, this is how I break down the business logic into manageable Java objects and so far it is working out for me.

When I reviewed the code, I observed that I've left the default Eclipse class type as e.g. class AddressList {} or class PhoneList {} etc

These classes are accessible to all the other classes and to the final layout in the same package without "extends". Java seems to default to "public".

Is this the normal behavior?



 
Ranch Hand
Posts: 239
12
Scala IntelliJ IDE Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's normal. The default Java behavior is called package-private. More info here. http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
 
Sheriff
Posts: 67671
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

AhFai Chan wrote: the default Eclipse class type as e.g. class AddressList {}


"Eclipse" class type? There's no such thing. Java is Java regardless of what editor you use.

These classes are accessible to all the other classes and to the final layout in the same package without "extends". Java seems to default to "public".


As pointed out, no. Try to access those classes from another package and you'll see how non-public they are.

 
AhFai Chan
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Scott Shipp wrote:That's normal. The default Java behavior is called package-private. More info here. http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html



Gotcha, thanks for the link.
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic