wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes reg import Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "reg import" Watch "reg import" New topic
Author

reg import

ahamed irshad
Ranch Hand

Joined: Feb 26, 2010
Posts: 31

are both same?

import java.a.*;
import java.a.b.*


You can do anything, but not everything
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
ahamed irshad
Ranch Hand

Joined: Feb 26, 2010
Posts: 31

then

import jxl.Write.*; and import jxl.Write.Workbook; are not same?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Feb 26, 2010
Posts: 31

thank you for your reply
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

ahamed irshad wrote:thank you for your reply

you are welcome
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reg import
 
Similar Threads
classpath issue
include class in other file?
Document to String
ODBC and xBase
WA #1.....word association