package pro;
import pro.point.s;
class point {
double x,y;
point(){}
point(double x,double y){
this.x=x;
this.y=y;}
void show(){
System.out.println("("+x+","+y+")");
}
static class s {
point p1,p2;
double s;
s(){}
s(point p1,point p2){
this.p1=p1;this.p2=p2;
s = Math.sqrt((p1.x - p2.x) * (p1.x - p2.x)
+(p1.y-p2.y) * (p1.y-p2.y));
}
void show() {System.out.println(s);}
}
}
public class dian {
public static void main(String[] args){
s s1 =new s();
point p1=new point(2,3);
point p2=new point(2,5);
p1.show();
p2.show();
s1.show();
}
}
uj5u.com熱心網友回復:
s s1 =new s(); 這行代碼放在 p1和p2實體化后,s1.show() 之前。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/274279.html
標籤:Eclipse
上一篇:各位大神,想問一下這段代碼為什么運行出來的距離結果一直為零啊
下一篇:有關return回傳值的疑問
