• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A question came to my mind???

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 354
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. Importing is just telling the compiler where to find the class which you have used.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic