java - 为什么类名与导入语句中使用的类相同
问题描述
下面的代码片段来自 ITDIAgentException.java 文件
有人可以帮我理解“为什么类名与导入语句中使用的类相同”(ITDIAgentException)
import com.ibm.di.entry.Entry;
import com.ibm.di.exception.ITDIAgentException;
public class ITDIAgentException extends Exception {
private Entry entry = null;
public ITDIAgentException(String paramString) { super(paramString); }
public Entry getEntry() { return this.entry; }
public void setEntry(Entry paramEntry) { this.entry = paramEntry; }
}
编辑
解决方案
您有两次 ITDIAgentException:一次在 import 语句中,一次在类定义中。您不能同时拥有这两者(将在代码中创建命名空间冲突),但您可以使用完整包访问 com.ibm.di.exception.ITDIAgentException(假设它与您正在创建的类不同)和班级名称。
import com.ibm.di.exception.ITDIAgentException;
public class ITDIAgentException extends Exception {
推荐阅读
- python - 必须是实数,而不是列表
- javascript - 直接滚动一个div
- python - 如何在 python kivy 中删除小部件
- angular - 使用本地存储在 Angular 中保存数据
- python - 按列将单个列表写入 csv
- vue.js - 使用名称中包含“-”的图标的vue离子问题示例“arrow-back”
- javascript - 如何将数据从 JSON 注入 HTML
- typescript - 当警报文本很长时,Ngx-bootstrap 警报破坏了 css
- google-colaboratory - 如何使用 YOLOv5 训练好的模型?
- javascript - Firestore add()不接受数组内的对象