*
The moose likes Beginning Java and the fly likes Is Importing extending 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 "Is Importing extending" Watch "Is Importing extending" New topic
Author

Is Importing extending

RajTilak Sivaluri
Greenhorn

Joined: Nov 13, 2010
Posts: 18
I tried to learn clearly about importing but now i am clearly confused what i am confused is that when i try to write as this it is working




Now my compiler is not producing any error but my doubt is if this is right my class is actually a subclass to class ArrayList .
which means it is no more a super class. And the other doubt is actually importing a class do mean that we are making our class a subclass to the imported class . Do post your comments
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

RajTilak Sivaluri wrote:
Now my compiler is not producing any error but my doubt is if this is right my class is actually a subclass to class ArrayList .
which means it is no more a super class

I don't get this sentence. If another class extends your class, then your class will be a super class to that extending class.
RajTilak Sivaluri wrote:
And the other doubt is actually importing a class do mean that we are making our class a subclass to the imported class . Do post your comments

Nope, import guides the compiler where to check the class which you've imported.


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

And, Welcome to JavaRanch!
RajTilak Sivaluri
Greenhorn

Joined: Nov 13, 2010
Posts: 18
Abimaran Kugathasan wrote:
RajTilak Sivaluri wrote:
Now my compiler is not producing any error but my doubt is if this is right my class is actually a subclass to class ArrayList .
which means it is no more a super class

I don't get this sentence. If another class extends your class, then your class will be a super class to that extending class.
RajTilak Sivaluri wrote:
And the other doubt is actually importing a class do mean that we are making our class a subclass to the imported class . Do post your comments

Nope, import guides the compiler where to check the class which you've imported.


What i was exactly saying was I created a class Myclass right !! but instead of using the import statement i extended the ArrayList class which i intended to use hence why why shouldn't i say that Myclass is a subclass to class ArrayList . Because i have done all the things to make it a subclass
RajTilak Sivaluri
Greenhorn

Joined: Nov 13, 2010
Posts: 18
And Yup Abhiram Thankyou
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Elaborating on Abimaran's reply to the second doubt:

In the code you have provided-


You must have observed that you never defined the class ArrayList in your source code, instead with the above syntax- java.util.ArrayList- you are using the ArrayList in the java.util package provided by the Java API. These java classes are organized in different packages depending on their functionality. There's another way as well to import the classes:


In the above code- you need not use java.util.ArrayList (which is called fully qualified name of the class) everytime you would want to refer to the ArrayList. Because the import you have used tells the compiler where to check for the ArrayList class.

Extending- is what makes one class super class of another/sub class of another class.

This is how you create a SubClass- SuperClass relationship (not considering Interfaces here as it might be confusing if you are starting with).

Also lets see a case where we are using importing and not Extending:



We can also use wildcard(*) in the import statement:



which indicates that you can be referring to any class from the package- java.util.

Mohamed Sanaulla | My Blog
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

RajTilak Sivaluri wrote:
What i was exactly saying was I created a class Myclass right !! but instead of using the import statement i extended the ArrayList class which i intended to use hence why why shouldn't i say that Myclass is a subclass to class ArrayList . Because i have done all the things to make it a subclass


I don't understand, what you've said above.

And My Name : Abimaran.
RajTilak Sivaluri
Greenhorn

Joined: Nov 13, 2010
Posts: 18
Extending- is what makes one class super class of another/sub class of another class.



This exactly the answer which i am looking for
RajTilak Sivaluri
Greenhorn

Joined: Nov 13, 2010
Posts: 18
Thank you Mohammad Sanullah .

@Abhiram : next time when i post my query i will try to elaborate it clearly this was my first post so could not make it clear
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

RajTilak Sivaluri wrote:...@Abhiram : next time when ...


You got his name wrong again
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37900
    
  22
mohamed sanaullah wrote: . . . You got his name wrong again
Thank you for noticing. It can cause a lot of annoyance when you copy somebody's name wrongly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Importing extending
 
Similar Threads
Doubt
Doubt: Anonymous InnerClasses
TypeCasting Doubt
doubt
iterate doubt