为什么我的程序运行总是 在类 myjava1.Test 中找不到 main 方法, 请将 main 方法定义为: public static v
packagemyjava1;classPoint{doublex,y;publicPoint(){x=0;y=0;}publicPoint(doublexx,doubl...
package myjava1;class Point { double x,y; public Point(){ x = 0 ; y = 0 ; } public Point(double xx,double yy){ x = xx; y = yy ; }public double getX(){ return x ; }public double getY(){ return y;}public double distanceOfPoints(Point p2){ double distance=0; double weight=p2.getX()-x; double hight=p2.getY()-y; distance=Math.sqrt(weight*weight+hight*hight); return distance; }}package myjava1;public class Test { public static void main(String[] args){ Point a=new Point(10,20); Point b=new Point(30,40); Point c=new Point(25,45); System.out.println("x="+a.getX()+"y="+a.getY()); System.out.println("x="+b.getX()+"y="+b.getY()); System.out.println("x="+c.getX()+"y="+c.getY()); System.out.println("a,b两点的距离为:"+a.distanceOfPoints(b)); }}
展开
2个回答
2017-11-22 · 知道合伙人互联网行家
关注
展开全部
class TeacherTest{ public static void main(String args[]){ Teacher s1=new Teacher("李四",123,20); Teacher s2=new Teacher(); System.out.println("姓名:"+s1.getName()+"学号:"+s1.getId()+"年龄:"+s1.getAge()); System.out.println("姓名:"+s2.getName()+"学号:"+s2.getId()+"年龄:"+s2.getAge()); } } //改成 public static void main(String args[]){ Teacher s1=new Teacher("李四",123,20); Teacher s2=new Teacher(); System.out.println("姓名:"+s1.getName()+"学号:"+s1.getId()+"年龄:"+s1.getAge()); System.out.println("姓名:"+s2.getName()+"学号:"+s2.getId()+"年龄:"+s2.getAge()); }
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询