内部类的用途

内部类的用途

实现多继承

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();  
    }  
}  

 

posted @ 2017-03-27 18:16  holos  阅读(229)  评论(0编辑  收藏  举报