Tuesday, August 20, 2019

If syntax in JAVA

If syntax:

if (condition)
{
if body;
}
The curly brasses are optional whenever we are taking single statements.
The curly brasses are mandatory whenever we are taking multiple statements.

Ex 1:-
class Test
{
public static void main(String[] args)
{
int a=10;
if (a>5)
{
System.out.println("if body / true body");
}
}
}

Ex 2:-
class Test
{
public static void main(String[] args)
{
if (true)
{
System.out.println("if body / true body");
}
System.out.println("hi rattaiah");
}
}

Ex 3:-
class Test
{
public static void main(String[] args)
{
if (false)
{
System.out.println("if body / true body");
}
System.out.println("hi rattaiah");
}
}

The curly brasses are optional whenever we are taking single statements.
The curly brasses are mandatory whenever we are taking multiple statements.


No comments:

Post a Comment

AME (Approval Management Engine)

AME (Approval Management Engine) : AME Stands for Oracle Approval Management Engine. AME is a self service web application that enables...