If else statement is used to execute some code only if a specified condition is true.If condition is true then the statement will be execute
Syntax of If Statement in JAVA
{
code to be executed if condition is true
}
Note : if is written in only lowercase letters. If we use uppercase letter like (IF) it will give error
Example of if statement
public class IfStatement {
public static void main(String[] args) {
int a = 20, b = 30;
if (a > b)
System.out.println("a > b");
if (a < b)
System.out.println("b > a");
}
}
Output of This Example
b > a
For More Example visit : http://www.programming-training.com/javaexamples/index.html
Please, stop wasting Internet space on re-explaining the basic language constructs. If you don't have an interesting topic to write on, don't write. Go learn a useful skill first.
ReplyDeleteIts really a nice and informative post you have shared, which is knowledgeable for most of the IT student because it is basic of programming. Thanks for sharing this post.
ReplyDeletesubject teachers