• 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

java package

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i know somewhat about packages concept..in this concept, we can create classes of our own and put it in package.. then how to access and use those classes in our program.. please explain by giving a simple java program..

thanks in advance
 
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should find most of your questions answered here, but come back if you have more.
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Bala Kan.

Packages are used for logical grouping of Java classes. You can use the package members by importing them in your Java class. Read more on how to import them here - Using Package Members

Packages helps in distinguishing classes when you are bound to use two or more classes with the same name. Hence note that two classes with the same name can never be present inside a package.

Note that there are access modifiers that restrict package member usage. Also the Java class files should be present in the directory named after the package it's present.

Sample code : Greetings.java resides in the package named myPackage and the Welcome class access it's method.

Greetings.java:


Welcome.java


As you are new here, I advise you to SearchFirst in JavaRanch and get good old discussions on the queries you have.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic