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?
Generics aren't for primitive types. Use Boolean
instead of boolean
.
public Tuple<Boolean, String> getResult() {
//your code goes here...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With