小编Hac*_*ann的帖子

A generic class that lets me have different return types (Java)

Today I've been working with generic/parametric types in java () exercising my polymorphism understanding but since quite some time now I've been having an issue where I would have a generic class with a single method that returns a value, the reason is because I want to be able to call a method and by context been able to have different return types

class dummy <E>{
    E value;
    public E getValue(){
         return value;
    }
class dummy1 extends dummy<E>{
    int value; …
Run Code Online (Sandbox Code Playgroud)

java generics polymorphism

2
推荐指数
1
解决办法
49
查看次数

标签 统计

generics ×1

java ×1

polymorphism ×1