请看代码,该程序运行的结果为什么是 接口常量???- interface Inter {
- public static final String s = "接口常量";
- public abstract void method();
- }
- class SubEx implements Inter {
- String s = "子类成员变量";
- public void method(){
- System.out.println("SubMethod");
- }
- }
- class Demo {
- public static void main (String[] args) {
- Inter in = getInstance();
- System.out.println(in.s);
- function( in);
- }
- public static Inter getInstance(){
- return new SubEx ();
- }
- public static void function (Inter in) {
- in.method();
- }
- }
复制代码
|