是不是在一个程序代码里不能有两个public 的class?那我这个怎么不能编译通过?
/*
* jex6_10.java
*
* Created on 2004年4月6日, 上午10:46
*/
package text_book;
import java.io.*;
/**
*
* @author E
*/
public class Spot //<<<<<<<<<-------就是这里有问题!!
{
private int x,y;
Spot(int u,int v){setX(u);setY(v);}
void setX(int x1){x=x1;}
void setY(int y1){y=y1;}
int getX(){return x;}
int getY(){return y;}
double dist(Spot R){ return Math.sqrt((x-R.x)*(x-R.x)+(y-R.y)*(y-R.y));}
}
class Trans
{
void move(Spot p,int h,int k)
{
p.setX(p.getX()+h);
p.setY(p.getY()+k);
}
}
public class jex6_10 {
/** Creates a new instance of jex6_10 */
public jex6_10() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Spot Q=new Spot(2,3);
System.out.println("Q点的坐标:"+Q.getX()+","+Q.getY());
Trans ts=new Trans();
ts.move(Q,4,5);
System.out.println("移动后的坐标:"+Q.getX()+","+Q.getY());
}
}
//我希望另一短代码能够利用这里面的Spot类!可是无效!
//另一段代码中的要引用Spot后,编译时说:
//jex6_10.java [14:1] class Spot is public, should be declared in a file named Spot.java