标签:
package com.mufeng.theeighthchapter; class Grain { @Override public String toString() { // TODO Auto-generated method stub return "Grain"; } } class Wheat extends Grain { @Override public String toString() { // TODO Auto-generated method stub return "Wheat"; } } class Mill { Grain process() { return new Grain(); } } class WheatMill extends Mill { Wheat process() { return new Wheat(); } } public class CovariantReturn { public static void main(String[] args) { Mill m=new Mill(); Grain g=m.process(); System.out.println(g); m=new WheatMill(); g=m.process(); System.out.println(g); } }
Grain Wheat
标签:
原文地址:http://blog.csdn.net/u013693649/article/details/51923344