Hi I have the following code for some reason it is throwing a type error: Expected String, Actual Object. Its a hashtable with string keys and linkedlist<string> values.
When iterating through these linkedlist I'm unable to set their values to a string variable. I've used to the getClass() method to ensure it is returning a string class which it is. I'm very confused and any help would be appreciated.
Enumeration t = Scope.keys();
String temp_string;
String temp_string2;
LinkedList temp_linkedlist;
while (t.hasMoreElements())
{
temp_string = (String)t.nextElement();
temp_linkedlist = (LinkedList)Scope.get(temp_string);
for(int num=0; num<temp_linkedlist.size(); num++)
{
//Prints out string from linked list
System.out.println(temp_linkedlist.get(num).getClass());
//throws error
temp_string2 = temp_linkedlist.get(num);
}
}
size()andget(num)on a linked list. It is better to iterate over it.