What is the if single-selection statement in Java: If the single selection is a statement in Java that evaluates to True or False meaning that if the statement results in True the work gets done on the true side if its evaluated false the true side gets ignored and the next line of code gets executed. Example as follows:
if ( X >= 5 )
System.out.println("X is greater then or equal to 5");
What is the while repetition statement in Java: The while loop in Java means exactly that, while statement is true that loop will execute until the condition is met or becomes false. Example:
while ( X <= 10 )
X = 2 * X;
How are these two statements similar? Both of this statements are similar that both have to evaluate if something is either true or false meaning that a certain condition has to be met in order for them to execute or skip a line of code.
How are they different? The main difference between the if single-selection and the while loop in Java are that the if condition only does what is being asked in the true side of the program, in a while loop in Java the line of code gets executed over and over until the condition is met so the loop terminates.
es.
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More