How to pack? The code is as follows
Package org.marsdroid;
Class Test
{
public static void Main (String args[]) {
SYSTEM.OUT.PRINTLN ("Hello package");
}
}
There are a few things to keep in mind about packaging:
1, after the packaging of the class, the compilation method is different. It needs to use the-D parameter, which is used to generate the appropriate folder according to the package name. And-D followed by the directory, "." Represents the current directory. For example, to compile the above class, you should
Javac-d. Test.java, if you want to put this class in the C-disk Windows folder, you should be javac-d C:\windows Test.java;
2, after packaging, the class name of this class has changed. becomes the "package name" + "." + "class name", compile the time can not directly write Javac Test.java, but to write Javac Org.marsdroid.Test.java;
3. The naming specification of the package name: 1) requires the package name all letters lowercase;
2) package name in general is your domain name upside down.
But the rule is dead, and the man is alive.
"Java4android" Video learning notes--packages and access rights (i)