Following on from a previous question, I have something else which I am unable to find conventially.
I have a hashset (trains) which is filled with elements. I'd like to write something which gets the position of that element in the hashset based on a string I pass to it.
I have something similar for hashtables which was taken from a question which someone else asked before
public static int getKey(String Station)
int place =0;
int keyLocation = 0;
for (Enumeration i=stations.elements(); i.hasMoreElements();)
for (Enumeration j=stations.keys() ; j.hasMoreElements();)
if( counter == place)
From this, I'd like to be able to return the integer of the element in the hashset.
If this cannot be done, then I would like to know (like my previous question) if it's possible to create a hashtable outside a method (as in, just inside the class) so that it can be referenced.
Thankyou in advance.