1.Phone
public class Phone {
String brand;
double price;
double size;
public void call(int cal) {
System.out.println("给xx打电话:" + cal);
}
public void playGames(String games) {
System.out.println("玩的游戏是:" + games);
}
@Override
public String toString() {
return "Phone{" +
"brand='" + brand + '\'' +
", price=" + price +
", size=" + size +
'}';
}
}
2.Phone_main
import java.util.Arrays;
public class Phone_mian {
public static void main(String[] args) {
Phone phone1 = new Phone();
phone1.brand = "iphone15promax";
phone1.price = 9999;
phone1.size = 8;
phone1.call(2);
phone1.playGames("sss");
System.out.println(phone1.brand);
System.out.println(phone1.price);
System.out.println(phone1.size);
System.out.println("*******************");
Phone phone2 = new Phone();
phone2.brand = "iphone15pro";
phone2.price = 999;
phone2.size = 6;
phone2.call(11111);
phone2.playGames("gfg");
System.out.println(phone2.brand);
System.out.println(phone2.price);
System.out.println(phone2.size);
Phone[] phones = new Phone[]{phone1, phone2};
System.out.println(Arrays.toString(phones));
}
}