定义包中的一个类
--------------------
//SomeSuper.java
package PKG1;
public class SomeSuper
{
protected int prot;
}
--------------------
下面是另一个类 由SomeSuper派生得到
---------------------------------------------------------
//PotectedTest.java
import PKG1.*;
class SomeSub extends SomeSuper{
void ok(){
prot=0;
System.out.println(prot);
}
void alsoOK(SomeSub subReference){
subReference.prot=0;
System.out.println(prot);
}
void notOk(SomeSuper superReference){
superReference.prot=0;
System.out.println(prot);
}
}
public class ProtectedTest{
public static void main(String[] args){
ss=new SomeSub();
ss.ok();
ss.alsoOk();
ss.notOk();
}
}
两个源文件在同一个目录H:\javastudy\Myjavas 下面 classpath=H:\javastudy\Myjavas;
编译出现一下错误
H:\javastudy\Myjavas\ProtectedTest.java:2: cannot access SomeSuper
bad class file: H:\javastudy\Myjavas\SomeSuper.java
file does not contain class SomeSuper
Please remove or make sure it appears in the correct subdirectory of the classpath.
class SomeSub extends SomeSuper{
^
1 error
Process completed.
甚是迷惑 ,不知道是什么原因,我感觉没有错误啊
那位高手指点!
感激不尽!