4.2 Expression, Declaration, Code Block and Method

Hello in the present video we have seen the keywords and and expressions in this course we will talk about space declarations and indentation which are and why they are important in Java applications let's start by entering a simple expression int var equalstwo if you remember from the previous video when we discussed expressions we know that discussed expressions we know that var equals... an expression so what is a declaration the statement and the whole line so the whole line that reads of in the Var equalstwo is a Java declaration so it's the whole line by adding the data type at the beginning of our expression and ending with a semicolon we have made a valid Java declaration we can also make increments like var plus plus or var minus minus which you have already seen in the videos on operations, let's go back to the comma points which allows to limit the declaration of variables you can have several declarations in one line for example equal to 5 and display the value of var I would recommend not to put declaration on the same line because it's more confusing and just a a little more effort to understand if it's all part of ... of the same line so as we can see our code works very well the fact that we put them on the ... you can put them on the same line if you you want and it's already true who's going to look at it... we feel that it is a complete statement because we have things that end with a semicolon and in Java a statement that ends with a semicolon the semicolon means that our declaration ends at this point here so it puts the concept of white space the white space between you expressions your operations and so on and so on in the example above for example we put space a space between the word int and then the word there variable to make sure that Java aware that are separated you can put more than 10 JAVA spaces look this space actually it will remove space internally another common place to put spaces between the name of the variable and the operators for example so in general you can do what you want with the white spaces and Java will ignore that white space and will work a very satisfactory way now let's talk about the concept of indentation in Java indentation makes the code as readable as possible for other users easier to modify but it's to show how the braces fit together and to show the logic of the program in a way that is as ... most organized way possible let's look for example at an if else statement if var equals ten 10 is displayed yes otherwise no is displayed and putting our printLn on the same line as the if and the printLn else on the same line as the else we see that the code is much more difficult to understand more difficult to understand with intellji the indentation is done automatically we can go in code and click on reforming code and there the code is much more readable and more understandable we have just seen the declarations the spaces and indentation in the next lessons we will focus more on the code blocks and keywords