Hi everybody, I'm just wondering what is the more eficient and compact way to write statements like this

if(site.next(1) == null) {
      return false;
}
if(site.next(2) == null) {
      return false;
}
if(site.next(3) == null) {
      return false;
}
  1. You can combine multiple tests in one if, in this case ORing them together, as in
    if ( site.next(1) == null || site.next(2) == null ...

  2. The contents of the if must be a boolean expression, so you don't need an if to turn that into a booelan result, eg
    return ! ( site.next(1) == null || site.next(2) == null

Thank you !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.