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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inherited library" Watch "inherited library" New topic

inherited library

Christophical Lee

Joined: Sep 02, 2010
Posts: 1

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!

Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link: http://aspose.com/file-tools
subject: inherited library
Similar Threads
writing to an XLS file using the jExcelApi library
What is right syntax to bypass virtual method call?
Dynamic class loading
CDI Question and jar