7
$\begingroup$

This Java snippet describes a quote from a movie. Can you find the quote?

void function (int number, int attempts) {

  {
    if (number > 1) {
      do {
        System.out.println('something');    
      } while (attempts > ++number);
    } else {
      System.out.println('something else');
    }
  } catch (Exception ex) {
    System.out.println('something bad');
  }

}
$\endgroup$
  • 1
    $\begingroup$ Where is the try? $\endgroup$ – me_digvijay Mar 30 '16 at 18:31
  • $\begingroup$ Possible duplicate of puzzling.stackexchange.com/questions/29858/program-rebus-vba $\endgroup$ – feelinferrety Mar 30 '16 at 18:48
  • $\begingroup$ Sorry, I didn't see that before I posted. The answer is indeed the same, but the riddle itself seems different enough to me. $\endgroup$ – Matt Mar 30 '16 at 18:56
  • 1
    $\begingroup$ I can't really agree about the duplicate. Sure, it's the same answer, but it's a different programming language, a different style, and a completely different method of getting that answer. $\endgroup$ – Khale_Kitha Mar 30 '16 at 18:56
6
$\begingroup$

Quote:

Do, or do not. There is no try.

Explanation:

The "catch" is missing the corresponding "try" statement, regardless of how the "do while" evaluates.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.