Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

Question about class inheritance

Thread view: 
Lian Liming - 21 Oct 2005 04:14 GMT
Hi all,

 I am new to java and now in the period of studying java language. I
have a question about class inheritance. If I declare "import ..."
statement to import a certain package in the a class, should I need to
import that package again in that class's  subclass if i want to use
the same package with the superclass?

 Thanks in advance!
Andrew Thompson - 21 Oct 2005 04:25 GMT
>   I am new to java and now in the period of studying java language. I
> have a question about class inheritance. If I declare "import ..."
> statement to import a certain package in the a class, should I need to
> import that package again in that class's  subclass if i want to use
> the same package with the superclass?

What happened when you tried it?  The compiler will tell you
if the sub-class is attempting to access a class that is not
available to it, via imports.  (Your computer will not explode
if you try it & 'fail').
Roedy Green - 21 Oct 2005 08:28 GMT
>  I am new to java and now in the period of studying java language. I
>have a question about class inheritance. If I declare "import ..."
>statement to import a certain package in the a class, should I need to
>import that package again in that class's  subclass if i want to use
>the same package with the superclass?

You don't need to import classes used by methods you inherit, but you
do need to reimport any classes you use yourself.

see http://mindprod.com/jgloss/package.html

You don't have to worry to much about imports. If you don't get them
right, the compiler will bitch until you add them.  If you use an IDE
like Eclipse it will prune out unneeded ones for you, or take generic
* imports and convert them into an explicit class list.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.