aspose file tools*
The moose likes Beginning Java and the fly likes inherited library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inherited library" Watch "inherited library" New topic
Author

inherited library

Christophical Lee
Greenhorn

Joined: Sep 02, 2010
Posts: 1
Hi,

if i have class Parent that has import lib.bird;

and i have Child that extends Parent but I want to use pro.bird instead, is that possible?

Can i override the library?
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

Is both your Child class & Parent class in the same file? In that case, use 'pro.bird'(fully qualified name) in your child class to refer 'bird' and this will override the whatever imports you have made for 'bird'.
For example, you might have imported Date from util package

but at a certain part of your program, you might want to use Date class that is inside sql package

would solve the ambiguity problem.

and Christophical Lee, Welcome to Ranch!


OCPJP 6
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Imports are only relevant for source files, not classes themselves. They are little more than a tool that allows programmers to be lazy. Without them you had to write java.util.List, javax.swing.JPanel etc all the time. So yes, if your two classes are located in different files, then you can import lib.bird in one file and pro.bird in the other.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: inherited library