• Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding packages  RSS feed

 
mahesh narayan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have two java classes say one.java and two.java .
Two.java is in a package structure com.arp where as one.java has no package specified. Is there a way to create an instance of one in two.java
help me out.

I think we cannot create an instance unless one is also kept under some package. Correct me if am wrong

rgds
MAhesh
[ January 11, 2005: Message edited by: mahesh n ]
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, you can't reference classes from another package without giving the complete package either with the classname or as part of an import.
As a class that's not in a package has as the package name an empty string you end up with just the classname which has the JVM look in the current package.

This is just one of the reasons you should ALWAYS use packages except for some very simple tests.
 
mahesh narayan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx a lot
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!