内部类的用途

内部类的用途

实现多继承

public class Goods {  
    private valueRate = 2;  
  
    private class Content implements Contents {  
        private int i = 11 * valueRate;  
  
        public int value() {  
            return i;  
        }  
    }  
  
    protected class GDestination implements Destination {  
        private String label;  
  
        private GDestination(String whereTo) {  
            label = whereTo;  
        }  
  
        public String readLabel() {  
            return label;  
        }  
    }  
  
    public Destination dest(String s) {  
        return new GDestination(s);  
    }  
  
    public Contents cont() {  
        return new Content();  
    }  
}  
原文地址:https://www.cnblogs.com/holos/p/6628097.html