package com.myPackage;
import java.util.ArrayList;
public class PackageStudy {
public static void main(String[] args) {
String[] names={"하나","둘","셋"};
int[] ages={1,2,3,4,5};
ArrayList list =new ArrayList();
//자동 완성기능 : Ctrl+SpaceBar
list.add("하나");
list.add("둘");
list.add("셋");
list.add(4);
list.add(5.55f);
list.add("여섯");
System.out.println(list.get(1));
//list.get(1) - Returns the element
// at the specified position in this list.
System.out.println(names[1]);
for(int i=0;i<names.length;i++){
System.out.println(names[i]);
}
System.out.println("====");
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
//while사용해서 표현해 보세요
System.out.println("====");
int i=0;
while(i<list.size()){ //조건은 true/false
System.out.println(list.get(i));
i++;
}
System.out.println("====");
int k=7;
/* k의 크기만큼 (ArrayList에서는 의미가 없음)
* 배열List을 만듭니다.
* (0) - 7 (1)- 14 (2) - 21 (3)- 28
* (4) - 35 (5) - 42 (6) 49
* for문이나 while문으로 배열의 값을
* 위처럼 넣으세요 */
ArrayList listK=new ArrayList();
for(i=0;i<=6;i++){
listK.add((i+1)*7);
System.out.println(listK.get(i));
}
}
}