user4188607
user4188607

Reputation: 9

can we insert a string into the hashtable object

Hashtable ExpiryRefData;
String icdExpiry;

try {
    ExpiryRefData = CAPSUtil.getRefData(EXPIRY);
    icdExpiry = (String) ExpiryRefData.get(EXPIRY);
}

can any body please explain how we are actually storing the string directly into the ExpiryRefData and how we are retrieving the values in the other string variable

Upvotes: 0

Views: 72

Answers (2)

Rajesh
Rajesh

Reputation: 2155

As per code stated here, CAPSUtil.getRefData(EXPIRY) returns a hashtable. Then ExpiryRefData.get(EXPIRY) returns object which is casted to String using (String). For more detils refer CAPSUtil.getRefData(EXPIRY) implementation.

As per java Hashtable reference

public class Hashtable<K,V>
This class implements a hash table, which maps keys to values. 

Any non-null object can be used as a key or as a value.

Upvotes: 0

tonychow0929
tonychow0929

Reputation: 466

Don't use a Hashtable. Use a Map<K, String> instead. If you need synchronized access, consider using a synchronized wrapper (refer to java.util.Collections).

(Edit: a Map<String, String> will do. If there is special need aHashMap` is enough.

Upvotes: 1

Related Questions