×

If, if..else , if..else..if commentary in Java

If, if..else , if..else..if commentary in Java

If, if..else , if..else..if commentary in Java


 

Java conditional statement

If , If…else , nested if commentary in Java


The If commentary in most cases is used to check a situation. It’s used to test whether or not a situation is right or false earlier than executing a commentary. 

For instance, it’s possible you’ll wish to take a look at if x is the same as y , if sure then upload x and y or another way.

There are different examples like –

Chances are you’ll wish to permit person to simply sign up their profile provided that they’re of sure age. And the instance is going on and on.

The if commentary is not only about trying out on my own, I might say it’s wanted in each program. In reality, you’ll be able to’t simply let customers input the rest they prefer, there must be regulations and laws, as an example, when you have a sort that permits person to go into their username and telephones quantity, the colon for telephone will have to settle for simplest numbers and if the person does now not observe up with the principles, an error will have to be displayed. That is the place if commentary is in use.

Let’s examine the way it works in Java 

Syntax for If commentary

   if ( expression ) {

//Remark ;

}

Examples

//by means of Zhullyblog

public magnificence pattern{

 public static void primary(String[] args) {

 int num = 10;

 //take a look at the commentary

  if (num > 1){

    Machine.out.println(“The quantity is bigger than 1”);

    }

  }

}

Screenshot

Java if statement

Consequence

If….else commentary


The if else commentary is used to check and in addition go back end result if the situation seems to be false.

Syntax

if ( expression ){

  //Remark ;

}

else {

 //Remark;

}

Examples

//by means of Zhullyblog

public magnificence pattern{

 public static void primary(String[] args) {

 int num = 10;

 //take a look at the commentary

  if (num > 1){

    Machine.out.println(“The quantity is bigger than 1”);

    }

    else {

      Machine.out.println(“The quantity is lower than 1”);

    }

  }

}

Screenshot

Java if else statement

Consequence

Let’s transfer


Break statement in Java


Continue statement in Java


Inheritance in Java


Please percentage 




Source link

send message
Hello,
Iam Guest Posting Services
I Have 400 sites
Status : Indexed All
Good DA : 40-60
Different Niche | Category
Drip Feed Allowed
I can instant publish
ASAP


My Services :

1. I will do your orders maximum of 1x24 hours, if at the time I'm online, I will do a maximum of 1 hour and the process is
completed.
2. If any of your orders are not completed a maximum of 1x24 hours, you do not have to pay me, or free.
3. For the weekend, I usually online, that weekend when I'm not online, it means I'm working Monday.
4. For the payment, maximum payed one day after published live link.
5. Payment via PayPal account.

If you interesting, please reply

Thank You

Regards,

iwan