0
    public boolean isChecked(Check check) {

    for (Measurement lookup : check.transcript) {
        if (lookup.getWidth().longEnough().equals(true)>3) {

        }

    }

Hey there I am looking to check if a width is long enough 3 times in my program however I cannot run this due to the error "Cannot invoke equals(boolean) on the primitive type boolean"

Am at a bit of a loss to why. Could it be due to .longEnough() having already returning a boolean value

    public boolean longEnough() {
    return this.lengthpass;
}
na wa
  • 3
  • 2

1 Answers1

1

First of all boolean is a primitive type and for primitive types you use == instead of equal, secondly you don't need to compare to true or false and can simply write

 if (lookup.getWidth().longEnough()) {

or when chcecking for false use the negator operator !

if (!isChecked(someCheck)) {

A little off-topic but maybe the best way to write the longEnough method is like below

public boolean isLongEnough(int value) {
    return value > this.lengthpass;
}
Joakim Danielson
  • 43,251
  • 5
  • 22
  • 52