当前位置:网站首页>Idea包的导入以及调用其中方法注意事项
Idea包的导入以及调用其中方法注意事项
2022-04-21 07:16:00 【_.JUN】
包的创立
首先我们在Idea里面新建了一个项目,
为的是以后大型项目的包的导入,
各包之间的方法调用,准备一下

这里我们把包建在src文件里
右键选择新建,里面选择package

其中com目录下已经折叠的名为XieZhiJun的包
而XieZhiJun目录下是Daily,Father,Son,Test;建立这么多包是为了演示一个项目中;
调用
现在我们再新建fatherPacker里面的class文件

package come.XieZhiJun.Test;
public class TestPackage {
public static void main(String []args){
fatherPackage p1=new fatherPackage();
而在fatherPackage
package come.XieZhiJun.Father.fatherPackage;
public class fatherPackage {
public fatherPackage()
{
System.out.println("fatherPackage已经导入");
}
}

发现爆红

不能识别出这个玩意
接下来就进入我们的正题了
导入包中的类

这里要注意一下,这里的导包是要一级一级的导入注意不是从src这个包开始的
而不是搞什么导入直接他的根文件夹就万事大吉了;要一级一级来;就像吃饭要一口一口吃


然后运行一下

这我们实际上已经在见过这种形式的导包,没有什么东西会无缘无故的产生
如
import java.util.Scanner;
//或者是
import java.util.*;
//其中"*"是按需导入的意思
这是java源码



这里我们看到了Scanner这个java文件
但是这里面对被导入的类是由要求的




改成public就可以了

版权声明
本文为[_.JUN]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_65358120/article/details/124122003
边栏推荐
- Yolov5 5.0调用本地摄像头
- Web 开发相关库或者软件
- 类中的泛型以及泛型类型
- Implementing AES encryption and decryption with PHP
- PHP Chinese to English initials
- Default password when installing Kali for virtual machine (VMX file source on official website)
- Unity -- Enumeration class
- Finds an array based on the value of a field in a two-dimensional array
- [PROJECT] small hat takeout (VI)
- 2022年电工(初级)考试题库及答案
猜你喜欢

图片素材 免费素材 图片素材网站 图片素材在哪里找 哪里有的图片素材下载 图片素材的用途 图片素材 产品图片素材网站 什么的素材可以 PPT素材

Actual combat of cloud native kubesphere multi tenant system

CouchDB vertical ultra vires
![[PROJECT] small hat takeout (V)](/img/63/fcbb5a748fe0442443a4784dee5ae4.png)
[PROJECT] small hat takeout (V)

Usage of go language log Uber go / zap / lumberjack

C51通过esp8266连接onenet(MQTT协议)上传温湿度+控制LED

sys. stdin. ReadLine and readlines and input ()

Why the existing modules in PIP list cannot be used in the new project has been solved

【项目】小帽外卖(五)

Capturing plaintext password with mimikatz in win10 system
随机推荐
Technical background and practical role of "industrial digitization"
Playwright click timeout attribute, the time to wait for the element to appear
Laravel print SQL
VMware提示恢复快照时出错找不到所需文件
Laravel EXECL import time becomes digital
Neptune w800点灯(中断)工程详解
Sword finger offer day22 bit operation (medium)
[glory of the king] skin - tensorflow
Replication of Apache skywalking SQL injection (cve-2020-9483)
Enum 枚举类型
go-ini的用法
2022 R2 mobile pressure vessel filling test question simulation test question bank and simulation test
Execute rule after MySQL where condition
上古神器Vim
Pycharm's latest method of importing PIL Library
Implementing AES encryption and decryption with PHP
网络安全空间导论密码学作业实现
PHP Chinese to English initials
sys. stdin. ReadLine and readlines and input ()
【Web系统课程设计】2022版