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

Java Program to convert Properties list into a Map

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
public class Demo {
	public static void main(String args[]) {
		Properties p = new Properties();
		p.setProperty("P", "1");
		p.setProperty("Q", "2");
		p.setProperty("R", "3");
		p.setProperty("S", "4");
		p.setProperty("T", "5");
		p.setProperty("U", "6");
		p.setProperty("V", "7");
		HashMap<String, String>map = new HashMap<String, String>((Map) p);
		Set<Map.Entry<String, String>>set =  map.entrySet();
		System.out.println("Key and Value of the Map... ");
		for (Map.Entry<String, String>m: set) {
			System.out.print(m.getKey() + ": ");
			System.out.println(m.getValue());
		}
	}
}

Advertisements
Loading...

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