I'm getting this Java Compile Error: "Unexpected Type required: variable found: value".
I realize in general, this means I'm probably doing something like 1.0 = mydouble; That's backwards. But, I'm not seeing my error in this code:
private Double bid;
public void setBid(double bid) {
Double.isNaN(bid) ? this.bid = 0.0 : this.bid = bid;
}
A ternary operator can only operate conditionally on values, not entire statements. Therefore, you would need to rewrite your code as:
this.bid = Double.isNaN(bid) ? 0.0 : bid;
Also, do you have a specific need to declare the field bid as a java.lang.Double (reference type) and not the primitive double?
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