Hi there.

I am currently trying programme my code(P) to lookup a hashtable from another class(F).
IS that possible?
Given that the hashtable is in the main method of (F).

Should I apply a toString() in (F) and make it a String variable before I call it into(P)?

If I do that, how do I reassimilate the (Key, value) format in (P).
There is always a case of "incompatible types" in the process. Any advice?

Thanks a million.

Regards, Jemima

Recommended Answers

All 4 Replies

I'm finding it hard to understand exactly what you are trying to achieve here.
F contains a HashTable; in P you want to perform a lookup on that HashTable - is that right?
If so, you can:
1. Make the HashTable public in F so P can access it directly
2. you can provide a getter method in F that returns the HashTable so P can use it.
or (probably best, depending on exactly what you want)
3. Keep the HashTable private in F, and have a public method in F that does lookups (accept the key as parameter, return the value). P can then call that to get the result of a lookup without having to know anything about the details of how the lookup works.

great. that's what i needed to know. and how exactly do i declare it public?

Like um..

public Hashtable h = new Hashtable();


Thanks a lot!


great great great. Thanks so much. I know I sound like a noob but I didnt know it could be declared that way! Thanks a bundle!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.