This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes a friendly class with public constructor and methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a friendly class with public constructor and methods" Watch "a friendly class with public constructor and methods" New topic
Author

a friendly class with public constructor and methods

Laudney Ren
Ranch Hand

Joined: Jan 06, 2002
Posts: 111
I'm just wondering the effects of a modifer of a class.
If the class itself is friendly or package private, can its methods, constructors and fields be declared pubic?
If so, can classes outside the package invode those methods and constructors or access the fields??
What's the effect of the modifier of a class?


" Veni, vidi, vici "<br />" I came, I saw, I conquered "
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4777
    
    8

Moving this to Java in General (Beginner)
Junilu
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
A class declared without an access modifier ("friendly" or "package" access) is only visible to other classes/interfaces in the same package. Making the methods public does not change this. So, no, classes outside the package cannot invoke the methods of this class.


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a friendly class with public constructor and methods