"Java4android" Video learning notes--packages and access rights (i)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.