What would be the better, whether should i access the static members using class name or using Object? Which one is preferred(low-cost effective)?
Today a thing stroke into my mind... Java supports multiple Interface Implementation but only single class extension to avoid ambiguous reference(data/members). Java manages to avoid method ambiguity but can't data ambiguity ;) Then the question stroke my mind static members should use using class name. But i am not sure which one is low-cost effective?
Today a thing stroke into my mind... Java supports multiple Interface Implementation but only single class extension to avoid ambiguous reference(data/members). Java manages to avoid method ambiguity but can't data ambiguity ;) Then the question stroke my mind static members should use using class name. But i am not sure which one is low-cost effective?
Code:
public class Test {
int a = 100;
}
interface InterfaceTest{
int a = 100;
}
class SubTest extends Test implements InterfaceTest{
SubTest(){
System.out.println("A: " + a); //Wrong one (ambiguous reference)
System.out.println("A: " + InterfaceTest.a); //Right one
}
}
Comment