| Author |
A question came to my mind???
|
Ammar Salem
Ranch Hand
Joined: Dec 29, 2007
Posts: 60
|
|
When we use Import statement in java, we simplay invoke a class from a certain package,that is fine with me,but this question keeps coming to my mind.IS IMPORTING A CLASS FROM A CERTAIN PACKAGE A KIND OF INHERITANCE??.I mean, is this statement " import java.util.Math ( I dont know wheather math class is in Util or not, but i am just giving an example),is that statement equal to this statement, say, public class MyMath extends Math, In conclusion, is Importing a type of Inheritance??? I hope I put my question right. thank you.
|
****************************<br />For Some Dreams.....<br />One Lifetime Is Not Enough.<br />****************************
|
 |
Abhinav Srivastava
Ranch Hand
Joined: Nov 19, 2002
Posts: 345
|
|
|
No. Importing is just telling the compiler where to find the class which you have used.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Importing is basically programmers being lazy. Without imports, you must write java.util.List, javax.swing.JFrame, etc. That is, with the full package. Now import simply tells the compiler: if you encounter List, you should look for java.util.List. If you encounter JFrame, you should look for javax.swing.JFrame. If you encounter class X, look in package java.io, java.net or java.util.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Qussay Najjar
Ranch Hand
Joined: Jan 18, 2008
Posts: 53
|
|
Many Java beginners think that import statement is to get the class you're using into your program which wrong for sure. using import statement is only giving the path of that class to use its methods into your own class.
|
Qussay NAJJAR
|
 |
 |
|
|
subject: A question came to my mind???
|
|
|