Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Insertion using Java collections

import java.util.LinkedHashMap;
import java.util.Map;
public class Demo {
	public static void main(String[] args) {
		Map<String, Integer>map = new LinkedHashMap<>();
		map.put("Jack", 0);
		map.put("Tim", 1);
		map.put("David", 2);
		map.put("Tom", 3);
		map.put("Kevin", 4);
		map.put("Jeff", 5);
		map.put("Katies", 6);
		map.put("Steve", 7);
		map.put("Andrew", 8);
		map.put("Angelina", 9);
		for (Map.Entry<String, Integer>entry: map.entrySet()) {
			System.out.println(entry.getKey() + " => " + entry.getValue());
		}
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.