3:38 pm - Sunday June 25, 2017

Typesafe view by specified Map in collection public static Map checkedMap(Map m, Class keyType, Class valueType)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

                        The method is also used to typesafe view by used specified map.

Example Program

import java.util.Collections;

import java.util.HashMap;

import java.util.Map;

public class collectionCheckedMap

{

	public static void main(String[] args)

	{

		HashMap<String, String> a = new HashMap<String, String>();

		a.put("1", "Happy");

		a.put("2", "Joy");

		Map<String, String> p;

		p = Collections.checkedMap(a, String.class, String.class);

		System.out.println("typesafe view of the map: " + p);

	}
}

Output

    typesafe view of the map: {2=Joy, 1=Happy}

 BACK

Filed in: Java Examples

Comments are closed.