The problem is that i got 2 classes. The first class has a method which created an object of the second class. Is it possible to get that object without having a return statement? And also not making it a field
Example:
//first class
public class First {
public First() {
}
public void aMethod(Object o) {
Second s = new Second(o);
}
}
//second class
public class Second {
public Second() {
}
}
The method is called via a click of a button.
EDIT: Sorry for the confusions. But the reason i dont want to change the code is because I'm making a JUnit test.
The two classes are actually jFrames and I'm trying to test the buttons. In the first class the method is called via a button. In the method it creates the second Jframe. In this Jframe i also want to test a button, thats why I need the instantiated jFrame object. In the aMethod() im also passing some paramenter, which the second JFrame needs. So I cant test It individually.