• Post Reply Bookmark Topic Watch Topic
  • New Topic

import statement

 
shanker sothi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say I have a package higherachy like this
net.xpack.ypack.zpack.abc
here abc is a "abc.class" file.
I want to use it in my current class.
so I import it as
import net.xpack.ypack.*;
when I access it with
zpack.abc.input();//here input is a public method under abc
There is an error?
please help me to solve this.
 
Arulkumar Gopalan
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have to import the package where it is located...
import net.xpack.ypack.zpack.*;
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although it looks as though zpack is "inside" ypack, as far as Java is concerned they're two separate unrelated packages. importing the classes in ypack doesn't tell the compiler to look in zpack, too.
 
shanker sothi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
Arul & Hill.
Shanker
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!