Reputation: 2298
I would like to access values passed to the constructor, in the initialize function. Current, I am passing them to some instance variables, and then accessing them from the initialize function. Is there a better/more concise way of doing this?
public class Example implements Initializable{
private int instanceVariable;
public Example(int exampleArg) {
instanceVariable = exampleArg;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
System.out.println(/* Somehow access exampleArg in the constructor */);
}
}
Upvotes: 0
Views: 68
Reputation: 38132
You can't access the local variables of a method/ constructor such as exampleArg
in another method but you can access member fields such instanceVariable
.
Upvotes: 2