首页 > 解决方案 > 使用泛型类型时如何打印编译器推断的有界类型?

问题描述

考虑以下代码段:

List<Exception> exceptionList = Arrays.asList(new Exception("344"));
List<Error> errorList = Arrays.asList(new Error("44"));

//consider a hypothetical function that can print the generic string corresponding
//to the type inferred by the following operation
showType((a == 4) ? exceptionList : errorList);

标签: javagenericstype-inferencejlsparameterized-types

解决方案


推荐阅读