0

Late static binding in Java, I have one parent class and two child

class Parent {
    public static final int ERROR_CODE = 1000;

    public static Integer fetchErrorCode()
        {
            return ERROR_CODE;
        }

}

class A extend Parent {
    public static final int ERROR_CODE = 1001;

}

public class B extend Parent {
    public static final int ERROR_CODE = 1002;

}

small example

A.fetchErrorCode() should be equal 1001
B.fetchErrorCode() should be equal 1002

Is this possible in Java?

shuba.ivan
  • 3,375
  • 7
  • 32
  • 104

0 Answers0