TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Java Tutorials

    Java if-else statement with Examples

    Overview

    Java if-else is a control structure and is used to make decisions based on conditions. We can use this statement to branch out code based on branch conditions.

    Java if-else statement

    If the given condition is True the program executes one path, and if the condition is false the program takes another path.

    Let’s see a simple example, below a sample piece of  Java code:

    public class JavaIFExample 
    {
     
     public static void main(String[] args)
     {
     
     int dummyVariable = 70 ;
     
     if(dummyVariable > 100)
     { 
     System.out.println("dummyVariable > 100 ");
     } 
     else 
     { 
     System.out.println("dummyVariable < 100 "); }
     
     }
    
    }

     

    Output of the Program

    dummyVariable < 100

     

    Control Structures

     

    The program output depends on what the if condition evaluates to True or False. The program executes the code depending on the value of dummyVariable in the above program.

     

    —

    Java Tutorials

    Java Tutorial on this website:

    https://www.testingdocs.com/java-tutorial/

    For more information on Java, visit the official website :

    https://www.oracle.com/java/

    Related Posts

    Java Performance

    Java Tutorials /

    Improving Java Performance with Multithreading

    Download Greenfoot Windows

    Java Tutorials /

    Download & Install Greenfoot on Windows

    Java Tutorials /

    Java Static Code Analysis

    Java Tutorials /

    Java Testing Tools

    Java Tutorials /

    Handle Multiple Exceptions in Java

    ‹ Java For Loop with Examples› Java switch statement

    Recent Posts

    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing Conversation Styles

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com