Return an object to use in another method
Hi i was just wondering if it was possible to return an object to use in another method. ill explain what i mean using exarmple code:
method1{
...
Qestion qestion = new Qestion(...);
for(...){
method2();
qestion.addAnswer(answer);
}
method2{
...
Answer answer = new Answer(...);
return answer;
}
the "..." are put there to get rid of unesscerary code.
Basically i use method1 to input a qestion and create an object "qestion" of class Qestion.
Then method2 is used get input of an answer and create an object "answer" of class Answer.#
I then want to pass it back to method1 for use with the method "addAnswer" from the qestion class.
Unfortunatly this apparently doesnt work :S
Any suggestions??
Thanks
Chris