package com.apple0829;
class Apple{
private String color;
private double weight;
// public Apple(){
//
// }
public Apple(String color,double weight){
this.color=color;
this.weight=weight;
}
public String toString(){
return "Apple[color=" +color +",weight="+weight+"]";
}
}
public class ToStringTest {
public static void main(String[] args) {
Apple apple=new Apple("红色",53.3);
System.out.println(apple);
}
}
构造方法练习
最新推荐文章于 2023-08-14 13:35:46 发布