arraylist2 Day10_class 예제 2023.08.25 예제 source code package day10; public class Product { // 필드 private String name; private int price; private int no; private static int num = 100; // 생성자 public Product() { no = num++; } // 메소드 public int getNo() { return no; } public void setNo(int no) { this.no = no; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getPrice().. 2023. 8. 28. Day08_ArrayList<>, DateTimeFormatter 2023.08.23 Day08 요약 - 배열을 사용할 때 ArrayList를 사용하면 길이 상관 없이 사용가능 - 현재 날짜, 시간을 받을 때는 DateTimeFormatter 사용 List - ArrayList List 변수명 = new ArrayList(); 배열에서는 길이를 정의해야 하지만, ArrayList에서는 자동으로 index 배정 (0, 1, 2, ...) // 아래 두 문장은 같은 의미, 다만 배열의 경우 length값이 필요 Student[] list = new Student[10]; ArrayList list = new ArrayList(); (변수이름).size() 해당 Array의 길이, 저장되는 만큼 늘어남 (변수이름).add(객체이름) 해당 객체를 변수에 저장 (변수이름).ge.. 2023. 8. 24. 이전 1 다음