62,628
社区成员
发帖
与我相关
我的任务
分享
public class Database {
public static List list1 = new ArrayList();
static{
list1.add(new Student("张三", 15, 123456));
/ist1.add(new Student("李三", 15, 123456));
list1.add(new Student("赵三", 15, 123456));
list1.add(new Student("王三", 15, 123456));
list1.add(new Student("刘三", 15, 123456));
list1.add(new Student("许三多", 15, 123456));
}
数组写法:
public class Database {
public static Goods[] goods = new Goods[5];
static{
goods[0] = new Goods("1", "电风扇", "124.23");
goods[1] = new Goods("2", "洗衣机","4,500.0");
goods[2] = new Goods("3", "电视机", "8,800.9");
goods[3] = new Goods("4", "冰箱", "5,000.88");
goods[4] = new Goods("5", "空调机", "4,456.0");
}
还有那种模拟集合的写法,也算动态修改数组内容,不过没找到内容就算了