Tuesday, 17 November 2015

Java Tutorial : Java if then else statement


Click here to watch in Youtube :
https://www.youtube.com/watch?v=WaSDgEPg1cM&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java if then else statement
Java Tutorial : Java if then else statement
ControlFlowDemo.java
class ControlFlowDemo
{
    public static void main(String[] args)
    {
        boolean flag = false;
        if (flag)
        {
            System.out.println("flag is true,inside if block.");
        }
        else
        {
            System.out.println("flag is false,inside else block.");
        }

    }
}
Output
flag is false,inside else block.
IfElseDemo.java
class IfElseDemo
{
    public static void main(String[] args)
    {

        int testscore = 81;
        char grade;

        if (testscore >= 90)
        {
            grade = 'A';
        }
        else if (testscore >= 80)
        {
            grade = 'B';
        }
        else if (testscore >= 70)
        {
            grade = 'C';
        }
        else if (testscore >= 60)
        {
            grade = 'D';
        }
        else
        {
            grade = 'F';
        }
        System.out.println("Grade = " + grade);
    }
}
Output
Grade = B
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/ControlFlowDemoIf-Then-Else-App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ControlFlowDemoIf-Then-Else-App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/08783475a968761a2cf4b3fc7275842653545b35/BasicJava/ControlFlowDemoIf-Then-Else-App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment