i have class static method invoked same class method , other class using class.staticmethod. this,
classa{ public void method1(){ --- --- method2(); } public static void method2(){ --- --- } } classb{ public void call(){ classa.method2(); //i have invoke through static method. } } public void main(...){ classa obj = new classa(); obj.method1(); }
is code follow standard (section 10.2 of java conventions)? or should invoke classa.method2() in classa method1. please dont duplicate, have looked @ other questions, don't talk scenario.
as the conventions state (thanks makoto), should refrain using object reference call static method. means, not this:
someobject.staticmethod();
instead, use class name this:
someclass.staticmethod();
of course, if calling static method within class ok (and preferred) this:
staticmethod();