So I would like to be sure (and also the hidden part is I like to have clean code)
When I'm using variable only one time I can create a method:
private List<Example> getExampleList() {
return Example.getInstance().getList();
}
Question:
If I use this only once, this is equivalent to:
private List<Example> exampleList = Example.getInstance().getList();What will the consequences be if I use my method many times instead of making a variable that stores this data? Will
javaload the value and return it even in cases when there was no reason for the value to change ?What will be the difference between the declaration and using the method?