Home Jsp Simple-jsp-example Nested If Statements

Related Tutorials


 
 

Share on Google+Share on Google+

Nested If Statements

Advertisement
We use the if condition to check if the particular condition is true then it should perform a certain task, and if a particular condition is not true then it should do some other tasks.

Nested If Statements

        

We use the if condition to check if the particular condition is true then it should perform a certain task, and if a particular condition is not true then it should do some other tasks. Consider a situation where we have to use multiple if conditions then there we have to use nested if statements.

 

Code of the program is given below:

 

 

<HTML>
  <HEAD>
    <TITLE>Nested if Statements</TITLE>
  </HEAD>
  <BODY>
    <H1>Nested if Statements</H1>
    <%
        double value = 5;
        if (value != 0) {
            if (value > 0)
               out.println("The result = " + (1 + value));
            else
               out.println("The result = " + (1 - value));
        }
    %>
  </BODY>
</HTML>

The output of the program is given below:

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 7, 2008

Related Tutorials

Discuss: Nested If Statements  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com