Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Nested if else in Java programming language

Posted on January 2, 2017December 26, 2019

Table of Contents

  • Nested if else in Java programming language
    • Nested if statement
    • Related

Nested if else in Java programming language

In this article , we will discuss the Nested if else in Java programming language

Nested if statement

Nested if-else statement,which means use one if – else statement inside another if – else statement. Inside means if body or else body. One or more condition are evaluated by the nested if statement. 

At the nested if statement, when condition becomes true if part executed and print display statement and then enter next inner-if loop, when condition becomes false  else part executed and print else part display statement and then may be exit or terminated nested if loop 

syntex

Nested if else in Java programming language
Nested if else in Java

Nested if else in Java programming language
Syntax

Flow diagram nested if

Nested if else in Java programming language
flow chart



program 1

 

class ifcon2{
public static void main(String args[]){
int age=17;                                                   //variable assinment
int marks=73;                                             //variable assinment

if(age>16){                                                  //outer if loop -for check age
                                                                    //if boolean epression is true print this statement
                                                                   //-and enter inner if loop
System.out.println(“age enough check your marks”);
//if boolean epression is false go to it’s else part

if(marks>74){                                   //inner if loop -for check marks
                                                                   //if boolean epression is true print this statement
                                                                  //-and exit the program
System.out.println(“ok you enter course”);
//if boolean epression is false print it’s else part
}else
{System.out.println(“not enough marks”);
}
}else
{System.out.println(“not enough age”);
//at the outer if loop,if boolean expression is false
                                                             //only print this statement 
}
}
}

in the progran, outer if loop condition is true but inner if condition is false so display above output

program 2
class ifcon2{
public static void main(String args[]){
int age=12;
int marks=75;
int rank=30;
if(age>11){
  if(marks>74){
if(rank>25){
System.out.println(“ok you enter course and get scholer”);
} else
{
System.out.println(“ok you enter course and not get scholer”);
                         }
}else
{
                   System.out.println(“ok you enter course and not get scholer”);
                   }
}else
        {System.out.println(“not enough age”);
}
}
}

Related post

While Loop in Java      while Loop in C++     While Loop In C

Do-while Loop in Java    Do-while Loop C++      Do-while loop in C 

For Loop in C++       For Loop in C         For loop in java

If condition C++       If condition in Java   If condition in C

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes