This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if statement question from JQ+

 
Jon Rosenbaum
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is the code snippet from one of the questions:

The thing I don't understand is how this compiles. I'm confused because there is a semi-colon at the end of the second if, which to me would make the else be its own statement that is not connected to an if. I'm obviously missing something since it does compile, so I was wondering if someone could please clear the cobwebs for me.
Thanks.
Jon
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The semi-colon is not at the end of the if statement. It is at the end of the println statement. In Java, every statement must end with a semi-colon.
Also, the else should line up with the second if.
------------------
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic