• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
Lookout! Runaway whale! Hide behind this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic