Please tell me how to transfer values from one method to another wherein the second method is trying to access the value from the first method and the second method takes in parameter from some other method.

public static int firstMethod() {
int foo = x;
// do something with foo
return foo;

/* second method takes parameter of same type
as first method returns */
public static int secondMethod(int bar) {
int out = bar;
// do something with out
return out;

public static void main(String[] args) {
int boo = 3;
int i = secondMethod( firstMethod ( boo ) );
System.out.println( i );

I think this is what you were after but let me know if this hasn't explained it too well... :)

if you dont mind can i send you the code, wherein i can then explain what is actually happening and what i am looking for.

better try to put your idea into words that actually make sense, because as it stands you make no sense at all.

See there are three methods (First, Second, Third).
The First Method is in a different class whereas the second and the third method are in the same class.
The first method is calling the third method by passing a string parameter.
In the third method there is an if clause wherein the clause is checking whether the Hashtable whose values are there in the second method is empty or not. If the values are not empty then the if clause would return hashtable values otherwise it would give an exception.
The second Method is accepting values of the hashtable from somewhere else so addition of an extra parameter in the third method would not be feasible enough.
I am getting an exception.

The "hashtable" will have to be an instance variable.

the declaration of the hashtable goes like this:

private hashtable hh= new hashtable();
the variable is declared inside the class but outside all methods.

if the declaration is correct then i dont know what the problem is because the values are coming in the the second method but it is showing as null in the third method ie the else part of the third method is being executed which is throwing an exception..

Show your "second" and "third" method (or at least every line of them that has to do with the hashtable) and the actual hashtable declaration line.

or tell us what kind of exception.