Return Tuple from Java Method
问题 I wrote a java class: public class Tuple<X, Y> { public final X x; public final Y y; public Tuple(X x, Y y) { this.x = x; this.y = y; } } but when I create a function like this: public Tuple<boolean, String> getResult() { try { if(something.equals(something2)) return new Tuple(true, null); } catch (Exception e){ return new Tuple(false, e.getMessage()); } However, I get the following compilation error: unexpected type required: reference found: boolean What I can do? 回答1: Generics aren't for