File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Packages" Watch "Packages" New topic


Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
This is from K&B.

It says if import statement from the second file(Needy3) is removed , the code will compile and run normally.

I don't get it.
If we are removing the import statement , how is the code accessing the class in the other file (

If some one has a good link for Packages , please it pass it on.
It is kind of confusing.

The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
The full name of the first class is "xcom.Usefull" and that is what you use in the second one: xcom.Useful uf = new xcom.Useful();

Using imports allows you, to omit the package name and write only the last part of the class name (here: "Useful").

In either case you need a correct setting of the classpath to enable Java to find the class file.
[ July 08, 2008: Message edited by: Ralph Jaus ]

SCJP 5 (98%) - SCBCD 5 (98%)
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Got it!

That wasn't so tough!
I agree. Here's the link:
subject: Packages
It's not a secret anymore!