-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfStatement.java
More file actions
45 lines (39 loc) · 1.31 KB
/
Copy pathIfStatement.java
File metadata and controls
45 lines (39 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package Phase1_CoreLanguage.DecisionMaking;
/**if statement is the most simple decision making statement.
* It is used to decide whether a certain statement or block of statements will be executed or not
* i.e if a certain condition is true then a block of statement is executed otherwise not.
* <p>
*
* Syntax:
* if(condition)
* {
* // Statements to execute if
* // condition is true
* }
* <p>
*
* Here, condition after evaluation will be either true or false. if statement accepts boolean values – if the value is true then it will execute the block of statements under it.
* If we do not provide the curly braces ‘{‘ and ‘}’ after if( condition ) then by default if statement will consider the immediate one statement to be inside its block. For example,
* <p>
*
* if(condition)
* statement1;
* statement2;
* <p>
*
* // Here if the condition is true, if block
* // will consider only statement1 to be inside
* // its block.**/
public class IfStatement {
public static void main(String args[])
{
int i = 10;
if (i > 15)
System.out.println("10 is less than 15");
// This statement will be executed
// as if considers one statement by default
System.out.println("I am Not in if");
//OUTPUT
//I am Not in if
}
}