my dog learned polymorphism*
The moose likes Java in General and the fly likes Acess Class in Default package!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Acess Class in Default package!!!" Watch "Acess Class in Default package!!!" New topic
Author

Acess Class in Default package!!!

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

Hi How could one acess class created in default pakage...


for eg I have a class A created in a default package .. now I want to access its member from a class B which is in some other pakcage..

Thanks


No Kaustubh No Fun, Know Kaustubh Know Fun..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

You cant.
It is a compile time error to import a type from the unnamed package.

http://docs.oracle.com/javase/specs/jls/se5.0/html/packages.html


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4164
    
  21

Maneesh Godbole wrote:You cant.
Which is one reason why you should never put classes in the default package.


Steve
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Acess Class in Default package!!!
 
Similar Threads
Private and Protected Constructors
hi default acess specifier
Default access
why iam able to access defualt specifier field even within a sub-class ?
Error on K&B exercise in Chap 10...