File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt with import and extends

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have heard that extends acts as a type of inheritence and import on the other hand imports...java file to a particular java file

..so my doubt is that..does both import and extend as they are inherting..?
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They have nothing in common ... 'extends' acts for inheritance. The import statements simply define which packages, classes, etc. you want to use in your class.

If you want to work with the Date object, you need to import java.util.Date. That does not mean you inherit it's behavior.
 
Steve Fahlbusch
Bartender
Posts: 602
7
Mac OS X Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Import does no such thing. It allows you to access items of packages without prefixing with the package name - like it was local to your class
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve is right. You can change any working Java program to work without imports - you will just have to write out each class name with their package names as well. So instead of "Date date = new Date();" you would have to write "java.util.Date date = new java.util.Date();". In the end, import statements are only meant to make life easier for us programmers.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic