I am stuck at this problem for ages. Basically I cannot convert Integer to int.
class CheckOdd implements Check<Integer>
{
public <Integer> boolean check(Integer num)
{
int i = (Integer) num;
return (i % 2 != 0);
}
}
I have tried usingint i = (Integer) object;
int i = (int) object;
intValue()
but still no luck. If I use int i = (Integer) object;
it produce error:incompatible types
.
If I use int i = (int) object;
it produce error: inconvertible types
.
Please Help. Thank you in advance.
You've replaced java.lang.Integer
with a generic type which you have named Integer
public <Integer> boolean check(Integer num) // <-- not a java.lang.Integer
should be
public boolean check(Integer num)
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