Search This Blog

UI/UX Design | Web Development | Mobile Application Development

Whether you need UI/ UX design, web development services, or mobile app development services, Qaabil Digitals will be more than happy to help you. We work with top software developers, designers, and project managers. We tailor our services to suit your exact needs. We closely look at your company, listen to your story, and bring about the best ideas and solutions that can help you drive solid results. We don’t just produce work that works. We produce work that matters. Get a quote now Or Talk to us

Saturday 25 June 2011

Nested if statement of java and its uses


Nested if:
                 It can be defined as an if statement containing another if statement with in its body/block. When we have to make one decision from multiple decisions we use nested if. A nested if is an if statement that is the target of another if or else. When you nest ifs, the main thing to remember is that an else statement always refers to the nearest if statement that is within the same block as the else and that is not already associated with an else. 

General syntax:
                           if (condition)      
                           {
                            if (condition)     
                            if (condition)         /* this if is associated with */
                            statement / block
                            else                      /* this else*/
                            statement / block
                            }
                            else                     /*and this else is associated with the most first if*/
                           statement / block
Here, in the block of if the second if in it is associated with the first if within the block. Remember an else always refers to the nearest if without an else and within the same block.

No comments:

Post a Comment

Share