3:42 pm - Sunday June 25, 2017

Retrieve all values in a Hashtable Collection values()

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

                          This function returns a collection view of the values contained in the map.

Example Program

import java.util.Hashtable;

public class HashtableValues 

{

	public static void main(String args[])

	{

		Hashtable htab1 = new Hashtable();

		htab1.put(1, "Add");

		htab1.put(2, "Sub");

		htab1.put(3, "Mul");

		htab1.put(4, "Div");

		System.out.println(" Hash table value: " + htab1);

		String returnval = (String) htab1.put(4, "Exp");

		System.out.println("Return value: " + returnval);

		System.out.println("New hash table value: " + htab1);

	 }

}

Output

   Hash table value: {4=Div, 3=Mul, 2=Sub, 1=Add}

   Return value: Div

   New hash table value: {4=Exp, 3=Mul, 2=Sub, 1=Add}

BACK

Filed in: Java Examples

Comments are closed.