If you omit the package statement, the class names are put into the default package, which has no name.This is the general form of the package statement:
package packageName;
To create a hierarchy of packages, separate each package name from the one above it by use of a period. The general form of a multileveled package statement:
package pkg1[.pkg2[.pkg3]];
A package hierarchy must be reflected in the file system of your Java development system.
A Short Package Example
package MyPack;
public class Main {
public static void main(String args[]) {
System.out.println("hi");
}
}
Then try executing the class, using the following command line:
java MyPack.Main
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |