Question: Hi, This is my code as an example for a if-else statement in Java. int x = 20; if ( x > 30 ) {

Hi,

This is my code as an example for a if-else statement in Java.

int x = 20;

if ( x > 30 ) {

System.out.println(x);

System.out.print ("This is an if statement");

}else {

System.out.println(x);

System.out.print ("This is an else statement");

In here we're saying if x > 30 then execute the if statement. But if it's not then move onto the else statement. So this code will execute as, 20 This is an else statement

The question I'm asked is, do you think that adding another variable would be hard to change the flow of the code? How would you go about this?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!