package cn.DongPhone;
public class Phone {
String brand;
float price;
String color;
}
//==================================================================
package cn.DongPhone;
import java.util.ArrayList;
public class GetPhone {
public static void main(String[] args)
{
ArrayList<Phone>arr=new ArrayList<Phone>();
addPhone(arr);
print(arr);
}
private static void print(ArrayList<Phone> arr) {
for(int i=0;i<arr.size();i++)
{
System.out.println(arr.get(i).brand+" "+arr.get(i).price+" "+arr.get(i).color);
}
}
private static void addPhone(ArrayList<Phone> arr) {
Phone p=new Phone();
p.brand="小米";
p.price=4564;
p.color="白色";
Phone ph=new Phone();
ph.brand="oppo";
ph.price=3000;
ph.color="红色";
Phone pho=new Phone();
pho.brand="vivo";
pho.price=3200;
pho.color="绿色";
arr.add(p);
arr.add(ph);
arr.add(pho);
}
}