Java Expressions, Statements and Blocks
In the previous Post, we have used expressions, statements and blocks without explaining them too much. Now that you know variables, operators, and literals, it will be easier to understand these concepts. Java expressions A Java expression consists of variables, operators, literals, and method calls. To learn more about method calls, visit Java Methods. For example, int score; score = 90 ; Here, score = 90 is an expression that returns an int . Take another example, Double a = 2.2 , b = 3.4 , result; result = a + b - 3.4 ; Here a + b - 3.4 is an expression. if (number1 == number2) System.out.println( "Number 1 is larger than number 2" ); Here, number1 == number2 is an expression that returns a Boolean value. Likewise, "Number 1 is larger than number 2" is a string expression. Java Statements In Java, each instruction is a complete unit of execution. For example, int score = 9 * 5 ; Here we have a statement. The complet...