Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Java If-else control flow | Java Tutorials Bestitworriors
Tips and Software development services. Java If-else control flow | Java Tutorials Bestitworriors
Java If-else control flow
Java If-else control flow | Java Tutorials Bestitworriors - If-else contains the block of code that execute when certain condation is true.We use if-else for condation base code.If condation is true the execute the if block code otherwise we can have multiple else - if to check next condation is true then execute the code other wise if not any of condation match the execute the else block.
Some Key Points of Java If-else
- if-else use for condation base
- If condation is true the execute if-block code
- if condation is not true then check next else if condaton and execute etc.
- If none of condation is match then execute else block
- We use certein condation in if-else to check the condation
- Less than: a < b
- Less than or equal to: a <= b
- Greater than: a > b
- Greater than or equal to: a >= b
- Equal to a == b
- Not Equal to: a != b
Code
public
class if_elses {
public static void main(String[] args) {
int firstnum = 5;
int secondnum = 10;
if ( firstnum > secondnum)
{
System.out.println("First number is greater then second");
} else if (firstnum == secondnum)
{
System.out.println("First number is equal to second");
} else
{
System.out.println("First number is less then second");
}
}
}
0 Comments