Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: 'if' Statement - if inside if

You can put an if statement inside another if statement.

Tutorial Details:

You can put an if statement inside another if statement.

Example -- series of tests
This code is correctly indented, but ugly and hard to read. It also can go very far to the right if there are many tests.

It's the semicolon! if you put a semicolon directly after the condition in an if statement, Java thinks it's finished with the body of the statement. The indentation of the next line, which is so important to human readers, is ignored by Java.

This is another error that's harder to make if you always follow the condition by an opening brace.


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/flow/if/50if-nesting.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
'if' Statement - if inside if

View Tutorial:
'if' Statement - if inside if

Related Tutorials:

Java Q&A, Open Java?
Java Q&A, Open Java?
 
Java decompilers compared - JavaWorld - July 1997
Java decompilers compared - JavaWorld - July 1997
 
Exceptions in Java - JavaWorld - July 1998
Exceptions in Java - JavaWorld - July 1998
 
Static class declarations
Static class declarations
 
Printing in Java, Part 4 - JavaWorld February 2001
Printing in Java, Part 4 - JavaWorld February 2001
 
Double-checked locking: Clever, but broken - JavaWorld February 2001
Double-checked locking: Clever, but broken - JavaWorld February 2001
 
Can double-checked locking be fixed? - JavaWorld May 2001
Can double-checked locking be fixed? - JavaWorld May 2001
 
Cut down on logging errors with Jylog
Cut down on logging errors with Jylog
 
Implement Design by Contract for Java using dynamic proxies
Implement Design by Contract for Java using dynamic proxies
 
Trace your steps in Java 1.4
Trace your steps in Java 1.4
 
Track wireless sessions with J2ME/MIDP
Track wireless sessions with J2ME/MIDP
 
Reinvented wheel
Reinvented wheel
 
Create your own type 3 JDBC driver, Part 3
Create your own type 3 JDBC driver, Part 3
 
How to build an interpreter in Java, Part 1: The BASICs (JavaWorld / May 1997 / by Chuck McManis)
How to build an interpreter in Java, Part 1: The BASICs (JavaWorld / May 1997 / by Chuck McManis)
 
Build an interpreter in Java -- Implement the execution engine (JavaWorld / July 1997 / by Chuck McManis)
Build an interpreter in Java -- Implement the execution engine (JavaWorld / July 1997 / by Chuck McManis)
 
Make a statement with javac!
Make a statement with javac!
 
Overcome J2SE 1.3-1.4 incompatibilities
Overcome J2SE 1.3-1.4 incompatibilities
 
SQL Database Access with DBTags
SQL Database Access with DBTags In a J2SE or J2EE application, Java Database Connectivity (JDBC) can be used to create a connection with a SQL database, create database tables, retrieve result sets, and update the database. To use a database from a Jav
 
Primrose - Free J2EE Database Connection Pooling Software
Primrose Primrose is a database connection pool, written in Java. Current containers support are Tomcat 4 & 5, and JBoss 3. There is also now a standalone version of primrose that can be used for applications not running inside a container.
 
What is the correct form of a MIDlet suite version number?
One character can be the difference between a successful installation and a failed attempt. Check your knowledge of MIDlet versioning.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.