Java

ArrayList, HashMap 연습

유호야 2021. 1. 12. 14:18
반응형
package com.yu.recipe;

import java.util.ArrayList;
import java.util.HashMap;


public class ArrayHash {

	public static void main(String[] args) {
		
		ArrayList<HashMap<String, String>> array = new ArrayList<HashMap<String,String>>();
		
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("파우", "유진");
		map.put("미래", "자수");
		map.put("에린", "미국");
		
		System.out.println(map);
		
		HashMap<String, String> pam = new HashMap<String, String>();
		pam.put("1", "jeden");
		pam.put("2", "dwa");
		pam.put("3", "trzy");
		
		System.out.println(pam);
		
		array.add(0, map);
		array.add(1, pam);
		
		System.out.println(array);
		
		System.out.println(array.get(0).get("미래"));
		
		
	}

}
반응형