본문 바로가기
JAVA

JAVA 자바 ArrayList, add, size(), get, hashCode

by Minius 2018. 2. 8.
반응형
package edu.collection;

import java.util.ArrayList;

public class CollectionEx1 {

	public static void main(String[] args) {
		
		String[] arr = new String[2];
		arr[0] = "apple";
		arr[1] = "orange";
		//arr[2] = "melon";
		
		for(int i=0; i al = new ArrayList();
		al.add("apple");
		al.add("orange");
		al.add("melon");
		
		for (int i = 0; i < al.size(); i++) {
			//String str = (String)al.get(i);
			String str = al.get(i);
			System.out.println(str);
			System.out.println(al);
			System.out.println(al.hashCode());
		}		
	}

}


댓글