package (packages)
Outline
Package is the folder
role: to solve the problem that the same file exists in a path, to facilitate classification management
divided packet may the functions, modules can follow
the format:
package 包名;
//多级包用.分开
//比如百度公司的工程命名都是com.baidu.xxx
Precautions:
- package statement must be the first executable code of the program
- package statement in a .java file can have only one
- If there is no package, no representation default package name
import keyword
import used to implement access between classes in different packages
we found that every time you use the full path of the category in different packages, you need a plus package. kind of hard. java package provides a guide function of
the format:
import 包名
//这种方式导入是到类的名称
import java.util.Scanner; //导入Scanner类
//如果想要导入该包的所有类,最后可以写*,但是不建议
import java.util.*; //导入util下面的的所有类