This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
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!
Don't get me started about those stupid light bulbs.
subject: Packages
Similar Threads
SCJP 5: Sef Test Q1 Page 781 or 789
Chapter 10 Q1 in Kathy Book
Static import Problem.
Ch 10 Q1 in K&B