Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reg import

 
ahamed irshad
Ranch Hand
Posts: 31
C++ Notepad Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are both same?

import java.a.*;
import java.a.b.*
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15484
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, they are not the same. In the first statement, you import everything in the package java.a, and in the second statement, you import everything in the package java.a.b.

Note that Java's packages are not hierarchical (even though the directory structure suggests that that's so) - importing java.a.* will not import the contents of package java.a.b.
 
ahamed irshad
Ranch Hand
Posts: 31
C++ Notepad Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then

import jxl.Write.*; and import jxl.Write.Workbook; are not same?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahamed irshad wrote:
import jxl.Write.*; and import jxl.Write.Workbook; are not same?


they are not same!but when you import using wildcard[import jxl.Write.*], compiler is smart enough to find out the required class and will change the import staement to import jxl.Write.RequiredClass
 
ahamed irshad
Ranch Hand
Posts: 31
C++ Notepad Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your reply
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahamed irshad wrote:thank you for your reply

you are welcome
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15484
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahamed irshad wrote:then

import jxl.Write.*; and import jxl.Write.Workbook; are not same?

No, but this is something different than your first question.

In this second question, Workbook is a class in package jxl.Write. If you import jxl.Write.* then you will import all classes from the package, including class Workbook.

But import jxl.Write.* will not import what's in packages that are "under" the package jxl.Write.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic