1:34 pm - Saturday March 25, 2017

Returns the value to which the specified key is mapped using V get(Object key)

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

Returns the value to which the specified key is mapped using  V get(Object key)

Example Program


package V1;

import java.util.Hashtable;

public class V1 {

public static void main(String args[]) {

// create hash table

Hashtable htable1 = new Hashtable();

 

//  put values in table

htable1.put(1, "A");

htable1.put(2, "B");

 

htable1.put(3, "C");

 

// get values at key 3

System.out.println("Values at key 3 is:"+htable1.get(3));

}

}

 

output:

Values at key 3 is:C

 

Explanation:

Returns the value to which the specified key is mapped, or null if this map     contains no mapping for the key More formally, if this map contains a mapping from a key k to a value v such that (key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

Parameters:

key – the key whose associated value is to be returned

Returns:

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Throws:

NullPointerException – if the specified key is null

 

BACK

Filed in: Z-A All Java Codes

Comments are closed.