Tutorialslot.com

youtube facebook twitter gmail pinterest

If Statement in Java


The "if" statements in java will be executed only if the given condition true. Mostly it accepts only boolean expression as condition.

Syntax:
if(condition)
{
statement;
}

For example,
if(true)
{
System.out.println("Have a Happy Life");
}

Output:
"Have a Happy Life"

Example:

public class If
{
  public static void main(String args[])
  {
    int ifs=7;
   if(ifs>3)
   {
    System.out.println("If statement is Success");
   }
  
   System.out.println("If statement Executed successfully");
  }
}

Output:
If Statement is Success
If Statement Executed successfully



Advertisement Powered By Google Adsense






IF YOU LIKE THIS TUTORIALS PLEASE SHARE

Share on whatsapp

POPULAR TAGS

Java java tutorials learn java java programming tutorial learn java online learning java professionals tutorials Multithreading Generics Object Oriented Language Methods Polymorphism Inheritance