-1

I'm done with this assignment, but I was wondering if there was a simpler way to achieve the same thing these code segments do?

public boolean noSolution ()
  {
     if (disc < 0)
        return true;
  }

public boolean equalRoots ()
  {
     if (disc = 0)
        return true;
  }

1 Answers1

-1

Do you mean?

public boolean noSolution() {
    return disc < 0;
}

You can just return the result of a Boolean expression.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130