wood burning stoves*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Packages" Watch "Packages" New topic
Author

Packages

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 (Useful.java).



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!
Thanks...

That wasn't so tough!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Packages
 
Similar Threads
SCJP 5: Sef Test Q1 Page 781 or 789
Chapter 10 Q1 in Kathy Book
Packages
Static import Problem.
Ch 10 Q1 in K&B