I am not too familiar with Java. I have the following question. I have seen similar posts on SO on this. What I am asking may be a bit different.
If I have the following situation
public class A {
public static void myMethod () {
// Does a whole lot of things including calls to DB
}
}
vs
public class A {
public void myMethod () {
// Does a whole lot of things including calls to DB
}
}
// In some other class
public void caller () {
A.myMethod (); vs new A().myMethod();
}
Reason I am looking at the non-static method is to ensure data is not shared between instances.
If the caller () method is being called often, would there be a performance cost because of the instantiation/class loading followed by the call to non-static method?