Let's say that I need to access variable 'asdf' about 1000 times.
What will be faster : create object Foo and pass it as argument to bar constructor and access it via getter or access Foo's number statically. Or those 2 approaches have equal performance ?
Class Foo {
public int asdf;
}
Class Bar {
Foo foo;
Bar(Foo foo1) {
this.foo = foo;
}
public void funcBar() {
foo.asdf;
}
}
Class Foo {
public static int asdf;
}
Class Bar {
public void funcBar() {
Foo.asdf;
}
}