class Point{
double x,y;

Point(double x,double y){
this.x = x;
this.y = y;
}

double getX(){
return x;
}
double getY(){
return y;
}
}class  Circle{
Point o;
double r;

Circle(Point o, double r){
this.o = o;
this.r = r;
}
  void test(double m,double n){
26 if(|o.x - m| * |o.x - m| + |o.y - n| * |o.y - n| > r * r)
27 System.out.Println("the Point not in the circle");
else
System.out.println("the Point in the circle");
}
}

public class TestPoint{
public static void main(String[] args){
Point p1 = new Point(3,5);
Point p2 = new Point(6,7);
37 Circle  mi = new Circle((3,5),5);

39 test.(6,7);

}
}请高手帮我找出错误。
26 :非法表达式
27:需要')'
System.out.Println("the point not in the circle");
                                                     ^
37:需要')'Circle mi = new Circle((3,5),5);
                             ^
39:需要标识符
test.(6,7);
         ^  

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【zyp627】截止到2008-07-22 20:48:14的历史汇总数据(不包括此帖):
    发帖的总数量:57                       发帖的总分数:790                      每贴平均分数:13                       
    回帖的总数量:28                       得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:57                       结贴的总分数:790                      
    无满意结贴数:1                        无满意结贴分:20                       
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:1.75  %               无满意结分率:2.53  %                  
    敬礼!
      

  2.   


    class Point {
    double x, y; Point(double x, double y) {
    this.x = x;
    this.y = y;
    } double getX() {
    return x;
    } double getY() {
    return y;
    }
    }class Circle {
    Point o;
    double r; Circle(Point o, double r) {
    this.o = o;
    this.r = r;
    } void test(double m, double n) {
    if ((o.x - m) * (o.x - m) + (o.y - n) * (o.y - n) > r * r)
    System.out.println("the Point not in the circle");
    else
    System.out.println("the Point in the circle");
    }
    }public class TestPoint {
    public static void main(String[] args) {
    Point p1 = new Point(3, 5);
    Point p2 = new Point(6, 7);
    Circle mi = new Circle(p1, 5);
    mi.test(6, 7); }
    }
    这是应该是你要的吧,错误有点奇怪。
      

  3.   

    if 后面地语句要不要分号啊?还有怎么显示我地>也有错误,都被搞晕了!
      

  4.   

    Java中没有关于绝对值的运算符,但是在Math类中有abs()方法可以求绝对值static double abs(double a) 
              返回 double 值的绝对值。 
    static float abs(float a) 
              返回 float 值的绝对值。 
    static int abs(int a) 
              返回 int 值的绝对值。 
    static long abs(long a) 
              返回 long 值的绝对值。 另外求平方可以用:
    static double pow(double a, double b) 
              返回第一个参数的第二个参数次幂的值。 所以 if( ¦o.x - m ¦ * ¦o.x - m ¦ + ¦o.y - n ¦ * ¦o.y - n ¦ > r * r) 
    可以改为:
    if ( (Math.pow(Math.abs(o.x - m), 2) + Math.pow(Math.abs(o.y - n), 2)) > Math.pow(r, 2) ) 
    还有要说明一点,java是对对象进行操作的,像(5,7)是不能被java识别的。在java中没有操作符重载的哦
      

  5.   

    import java.io.*;
    class Point{
    double x,y;Point(double x,double y){
    this.x = x;
    this.y = y;
    System.out.print("sjhdfkhwekslkd");
    }double getX(){
    return x;
    }
    double getY(){
    return y;
    }
    }class  Circle{
    Point o;
    double r; Circle(Point o, double r){
    this.o = o;
    this.r = r;
     System.out.print("sjhdfkh==-slkd");

    }
    void test(double m,double n){
    if( (o.x - m) * (o.x - m) + (o.y - n) * (o.y - n) > r * r)
    System.out.println("the Point not in the circle");
    else
    System.out.println("the Point in the circle");
    }
    }public class TestPoint { /**
     * @param args
     */
    public static void main(String[] args) {

        System.out.print("sjhdfkhwekslkd");
    Point p1 = new Point(3,5);
    Point p2 = new Point(6,7);
    System.out.print("sjhdfkhweksl+\n");
    Circle  mi = new Circle(p1,5);
    System.out.print(String.valueOf(mi.r));
    System.out.print(String.valueOf(mi.r)+"\n");
    mi.test(6,7); 
    // TODO 自动生成方法存根 }}
    和上面的那个亲兄弟一样,没问题
    输出结果为:
    sjhdfkhwekslkdsjhdfkhwekslkdsjhdfkhwekslkdsjhdfkhweksl+
    sjhdfkh==-slkd5.05.0
    the Point in the circle
      

  6.   

    用不着绝对值函数,因为(o.x - m) * (o.x - m) + (o.y - n) * (o.y - n)的结果一定是一个正数.
      

  7.   

    class Point { 
    double x,y; 
    Point(double x,double y){ 
    this.x = x; 
    this.y = y; 
    }
    double getX(){ 
    return x; 
    }
    double getY(){ 
    return y; 
    }
    }class  Circle{ 
    Point o; 
    double r; 

    Circle(Point o, double r){ 
    this.o = o; 
    this.r = r; 
    }
      void test(double m,double n){ 
    if((o.x - m ) * (o.x - m ) + (o.y - n) * (o.y - n ) > (r * r))
    System.out.println("the Point not in the circle"); 
    else 
    System.out.println("the Point in the circle"); 
    }
    }public class TestPoint {
    public static void main(String[] args){
    Point p1 = new Point(3,5); 
    Point p2 = new Point(6,7); 
    Circle  mi = new Circle(p1,5); 
    mi.test(6.0,7.0);
    }
    }你想写的的是这个吧??
      

  8.   

    1 求绝对值java中没有| | 号的,可以象楼上的哥们说的用Math.abs处理
    2 创建 Circle对象  Circle c = new Circle(new Point(3,5),5);
    3 对于Circle 中的方法test,当c.test();调用 不能直接调用的