4.4 Déclation, If et else
Hello the previous video we discussed white space and adaptation it’s now time to move on to keyword I will discuss blocks of code several details what I will do first is to browse a little more the word-if key to familiarize yourself with the different ways to use it in Java we have several conditions we will go through all the conditions during the courses that will follow in this particular shot we will see the condition if first we will declare a variable value that had equal to 10 thanks to the words-keys we will create a declaration of the kind if value equal to 10 we make a comparison that means that using two equals to perform the comparison then we will do printLn on value this is the first use of the if we can use it anyway it is means that we will get rid of the braces in the code In other words we get rid of the blank code if we have a line at execution we will have the same result an instruction that we can have executed after the test so in this case if the value equals 10 if it is true it will launch and display 10 but otherwise if the value is not equal to 10 it will ignore the line and move to the next line with this method there it is possible to use only one line after the condition if we change the condition that we say value equal to 11 we should not have 10 display on the screen because the comparison will fail but the 2nd line is displayed in what happens is that those-ci perform whatever happens because it’s not on the line after the test if I generally recommend even if you have only one line to use a block of code that’s-to say to put braces because this is the most visible code possible and the most understandable In the next video we will continue to see the different ways of using an if and then we will also see the else so to the next