• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding packages

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx a lot
 
reply
    Bookmark Topic Watch Topic
  • New Topic