Net-informations.com
SiteMap  | About    

What is package in Java?

Java package is a group of similar types of classes, interfaces and sub-packages. Conceptually you can think of packages as being similar to different folders on your computer. Packages are used in Java in order to prevent naming conflicts , to control access, to make searching/locating and usage of classes, interfaces, enumerations, annotations etc. Although interfaces and classes with the same name cannot appear in the same package, they can appear in different packages. This is possible by assigning a separate namespace to each package.

Syntax

Example

How to compile java package

Syntax

Example

The -d switch specifies the destination where to put the generated class file. If you want to keep the package within the same directory, you can use . (dot).







net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.