java -packages and import packages

1. Package: It is essentially a folder.
2. The package uses "." to indicate the hierarchical relationship. For example, the directory represented by p1.p2.Test is \p1\p2\Test.class.

Create a new package in the idea:
insert image description here

name it: com.miao.entity
and display it in the folder like this:

insert image description here
Create a new class Person under the com.miao.entity folder:

insert image description here
the arrow points to the declaration of the package, indicating the current class , belonging to the entity package:

insert image description here
Then create a new package: com.miao.dao
found under the folder:
insert image description here
Then create a new Java class under dao named Testperson
and create a Person object under the folder:
insert image description here
you can see the error A:
Because there is no import of Person:
the import package is: ALT+Enter
insert image description here

Then just fine:

Guess you like

Origin blog.csdn.net/weixin_55775980/article/details/127058902