"boolean tree == true;while(tree){}"

Find the exeception xd!

  • 2
    No exception there. It's more of a compile error.
  • 0
  • 0
    @TheFBI Well if this is Java, you can't initialize a variable with a double =

    And when that's fixed, well it's just an infinite empty loop, but still a valid instruction.
  • 1
    And if the whole thing is a string... Well it's not affected to any variable. Still a compilation error.
  • 0
    @CtrlAltElite JVM throws the loop out tho, since there is nothing in it. Java discards empty loops, which is a pain when you're trying to wait a bit...

    He's also missing a semicolon after. There's no exceptions, just compile time errors like you said.
  • 0
    @nanoandrew4 If you just want to wait a moment why not use Thread.sleep() instead of empty loops?
  • 0
    @loopback Yeah but when I moved from C++ to Java I was super confused as to why my waiting loops didn't work 😶 now I know better, I just recently watched some stuff on the JVM optimizing code and heard that those loops get tossed... Good to finally know what happened to those.
Add Comment