대학교 3학년 인턴 JAVA. - 집합.

1019 단어 실습
import java.util.*; public class ArraylTest {
public static void main(String[] args) {
    ArrayList LBL = new ArrayList(); // 
    System.out.println(" " + LBL.size());// 
    yuangong yg = new yuangong(" ",21,4000);// 
    yuangong yh = new yuangong(" ",21,4000);
    LBL.add(yg); // 
    LBL.add(yh);
    // 
    for(int i = 0; i < LBL.size(); i++) {
        // , 0 
        yuangong temp = (yuangong)LBL.get(i);
        System.out.println(" " + temp.getName());
    }
}

}//직원 클래스, 구성 방법class yuangong {private String name;public String getName() {return name;public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public float getAvg() { return avg; } public void setAvg(float avg) { this.avg = avg; } private int age; private float avg; public yuangong(String name, int age, float avg){ this.name = name; this.age = age; this.avg = avg; } }

좋은 웹페이지 즐겨찾기