62,623
社区成员
发帖
与我相关
我的任务
分享
public class Apple {
private String shape;
private String color;
// 无参数传递
public Apple() {
shape = "";
color = "";
}
// 传递形状和颜色
public Apple(String shape, String color) {
this.shape = shape;
this.color = color;
}
// 传递形状
public Apple(String shape) {
this.shape = shape;
this.color = "";
}
// 传递颜色
public Apple(String color) {
this.color = color;
this.shape = "";
}
// 当然也可以通过SET方法传递
public void setShape(String shape) { this.shape = shape; }
public void setColor(String color) { this.color = color; }
}
public class Apple {
String shape;
String colour;
Apple()
{
shape="";
colour="";
}
public String eat()
{
//eating
return "好吃!";
}
public String getShape()
{
return shape;
}
public String getColour()
{
return colour;
}
}
class car {
String name = "奇瑞QQ";
String color = "红";
void run(){
System.out.println("每小时80公里");
}
}