• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

reg import

 
Ranch Hand
Posts: 31
Opera C++ Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are both same?

import java.a.*;
import java.a.b.*
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Opera C++ Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
then

import jxl.Write.*; and import jxl.Write.Workbook; are not same?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Opera C++ Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your reply
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ahamed irshad wrote:thank you for your reply


you are welcome
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic