I'm creating a jdbm hash table and putting in a String[] as the value, but when I try to get() it, it returns type Object and does not like being casted back to String[]. What is going on and why not?
Expand|Select|Wrap|Line Numbers
- hashtable = HTree.createInstance( recman );
- .
- .
- .
- String[] test= {"test hard, testhard2", "romeo must test", "live rich or test trying"};
- String[] romeo = {"romeo must die","romeo and juliet","romeo and juliet 2"};
- hashtable.put( "die", die );
- hashtable.put( "die", romeo );
- .
- .
- .
- // Error Line:
- String[] titleArr = hashtable.get("die");
- Error: Uncompilable source code - incompatible types
java.lang.String cannot be cast to [Ljava.lang.String
---------------------------------------------
FIXED before I finished my post, for anyone else who has the same issue. Experts, comments/feedback are welcome.
Explanation of my bug:
I was using an existing jdbm file that already had these keys with String values, not an array. recreated it and then the explicit casting worked. But I didn't use String[] anymore I used java.util.HashSet because my lists could get pretty large.
Thanks,
Dan