public class Array172 {
public static void main(String[] args) {
Item[] items = new Item[6];
items[0] = new Item("java", 6000);
items[1] = new Item("파이썬", 1000);
items[2] = new Item("스크립트", 2000);
items[3] = new Item("깃허브", 3000);
items[4] = new Item("리액트", 4000);
Item[] items1 = new Item[]{new Item("인공",1000)};
Item[] items2 = {new Item("가나",2000)};
for (Item iter : items){
System.out.println(iter);
}
}
}
class Item{
private String name;
private int price;
public Item(String name, int price) {
this.name = name;
this.price = price;
}
public String getName() {
return name;
}
public int getPrice() {
return price;
}
@Override
public String toString() {
return "Item{" +
"name='" + name + '\'' +
", price=" + price +
'}';
}
}