Usage of package statements in Java

Source: Internet
Author: User
 
From http://zhidao.baidu.com/question/170311786.html
 
Using Ultra Edit to program a package is the same as writing a package without a package. There is only one difference in Compilation: Package com. util; public class myjava {}. If there is a package program: javac-D. myjava. JavaCurrentDirectory to generate a com folder, which contains an util folder, which contains a myjava. class File Execution command: Java COM/util/myjava if there is no public class myjava package {} is javac myjava. java executes Java myjava
 
 
 
Understanding: package is used to specify the folder name. For example, Com. util has a folder named com, and COM has another folder named util. Util is the specific package (folder) where the class myjava is located ). When creating a folder, use the javac-D Class Name. Java to compile the folder.
 
 
If you want to generate a class file in another directory instead of the current directory, you can add a path after javac. For example, javac-d F:/javaproject myjava. Java generates the com folder, util folder, and myjava. Class file under the F:/javaproject directory.
 
 

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.