当前位置: 技术问答>java相关
菜鸟学java送分
来源: 互联网 发布时间:2015-06-22
本文导语: 程序1. package com.jack.examples.classes; public class Rect{ public int x1,y1,x2,y2; public Rect(int x1,int y1,int x2,int y2){.....} } 程序1 javac Rect.java通过。 程序2. package com.jack.examples.classes; public class RectTest{ public static void main(St...
程序1.
package com.jack.examples.classes;
public class Rect{
public int x1,y1,x2,y2;
public Rect(int x1,int y1,int x2,int y2){.....}
}
程序1 javac Rect.java通过。
程序2.
package com.jack.examples.classes;
public class RectTest{
public static void main(String [] args){
Rect r1 = new Rect(1,1,4,4);
}
}
程序2 javac RectTest.java时出现:
RectTest.java:4: Class com.jack.examples.classes.Rect not found in type declaration.
Rect r1 = new Rect(1,1,4,4);
why??????????????????????
package com.jack.examples.classes;
public class Rect{
public int x1,y1,x2,y2;
public Rect(int x1,int y1,int x2,int y2){.....}
}
程序1 javac Rect.java通过。
程序2.
package com.jack.examples.classes;
public class RectTest{
public static void main(String [] args){
Rect r1 = new Rect(1,1,4,4);
}
}
程序2 javac RectTest.java时出现:
RectTest.java:4: Class com.jack.examples.classes.Rect not found in type declaration.
Rect r1 = new Rect(1,1,4,4);
why??????????????????????
|
将两个CLASS一起编译
|
用如下方法编译一定通过
javac -d . *.java
javac -d . *.java
|
你编译后的Rect.class代码没有放到com.jack.examples.classes包中
所以编译器找不到Rect类的申明,The more you can get from yefaqi@eastcom.com
所以编译器找不到Rect类的申明,The more you can get from yefaqi@eastcom.com