package和import

yangyira2 2006-09-26 05:23:05


//class ComplexNumber
package complex;
class ComplexNumber
{}
把ComplexNumber 打包到d:\


设置classpath=%classpath%;d:\
//class ImpComplex
import complex.*;
class ImpComple
{
ComplexNumber n=new ComplexNumber();
}


出错
ImpComplex.java:4: 无法访问 ComplexNumber
错误的类文件: null
无法访问文件: d:\ComplexNumber.java (系统找不到指定的文件。)
请删除该文件或确保该文件位于正确的类路径子目录中。
ComplexNumber n=new ComplexNumber();
...全文
172 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangyira2 2006-09-26
  • 打赏
  • 举报
回复
把ComplexNumber 和 ImpComplex类设置为public 都还不行!!!
yangyira2 2006-09-26
  • 打赏
  • 举报
回复
还是不行啊!!!
Onelee 2006-09-26
  • 打赏
  • 举报
回复
顶下
lsrj 2006-09-26
  • 打赏
  • 举报
回复
ding
CXBID 2006-09-26
  • 打赏
  • 举报
回复
把class ComplexNumber设置为public
default类型不能被异包访问
qiuqiupeng 2006-09-26
  • 打赏
  • 举报
回复
把class ImpComple设置为public
default类型不能异包访问
superslash 2006-09-26
  • 打赏
  • 举报
回复
ComplexNumber n=new ComplexNumber();
===============================
置于一个方法中

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧