不是说包的命名规范是全小写吗,为什么例子里“com.imooc.MyClass”中有大写字母?
回答:因为你这个引入的是某个包下面的类,最后这个大写的MyClass是一个类。这不是一个包的名字
回答:因为你这个引入的是某个包下面的类,最后这个大写的MyClass是一个类。这不是一个包的名字
2017-07-15
最新回答 / 忆_卿
因为你写的是 有参有返回值方法,不能直接在里面输出 得要有一个返回值。 public static int sum() { int sum=score1+score2; return sum; }
2017-07-14
public class Square extends Shape {
public Square(double length, double width) {
super(length, width);
}
public void getArea() {
System.out.println("矩形的面积是:" + length*width);
}
public void getPerimeter() {
System.out.println("矩形的边长是:" + (length+width)*2);
}
}
public Square(double length, double width) {
super(length, width);
}
public void getArea() {
System.out.println("矩形的面积是:" + length*width);
}
public void getPerimeter() {
System.out.println("矩形的边长是:" + (length+width)*2);
}
}
2017-07-14
public class Circle extends Shape {
public Circle(double length) {
super(length);
}
double π = 3.14;
public void getArea() {
System.out.println("圆形的面积是" + π*length*length);
}
public void getPerimeter() {
System.out.println("圆形的边长是:" + 2*π*length);
}
}
public Circle(double length) {
super(length);
}
double π = 3.14;
public void getArea() {
System.out.println("圆形的面积是" + π*length*length);
}
public void getPerimeter() {
System.out.println("圆形的边长是:" + 2*π*length);
}
}
2017-07-14
public abstract class Shape {
double length,width;
public Shape(double length,double width) {
this.length = length;
this.width = width;
}
public Shape(double length) {
this.length = length;
}
public abstract void getArea();
public abstract void getPerimeter();
}
double length,width;
public Shape(double length,double width) {
this.length = length;
this.width = width;
}
public Shape(double length) {
this.length = length;
}
public abstract void getArea();
public abstract void getPerimeter();
}
2017-07-14