Detailed package-import

/*
Package mechanism:
1. In order to solve the problem of class naming conflicts, add a namespace before the class name (package mechanism)
2. Use the package statement in java to define the package (single package, multiple packages) 3. The package
statement can only appear The format defined by 4.package in the first line of the .java source file
usually adopts the reverse order of the company domain name.
Example : com.bjpowernode.oa.system The
above contains the meaning: bjpowernode company develops the oa project, and system is one of the modules of the oa project
5 .The full class name is with the package name
6. The java source file with the package statement must be compiled like this:
javac -d generate path java source file path
*/


package com.bjpowernode.javase.day5;
public class fuck6{ public static void main(String[] args){ System.out.println("main method invoke"); }





}


package com.bjpowernode.javase.day5;


public class fuck7{
public static void main(String[] args){
fuck6 f=new fuck6();
System.out.println(f);//com.bjpowernode.javase.day5.fuck6@15db9742
}

}

package com;


//The import statement can introduce other classes
//The import statement can only appear under the package statement, above the statement defined by the class
import com.bjpowernode.javase.day5.*;


public class fuck8{ public static void main( String[] args){ fuck6 f=new fuck6();//fuck6.class file cannot be found, there is no System.out.println(f) in com package; } }










Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325891279&siteId=291194637