

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java if statement example
Flow Diagram
If the boolean expression evaluates to true, then the if a block of code will be executed, otherwise else block of code will be executed.
Example
public class Test { public static void main(String args[]) { int x = 30; if( x < 20 ) { System.out.print("This is if statement"); } else { System.out.print("This is else statement"); } } }
Output
This will produce the following result −
This is else statement
- Related Questions & Answers
- Java nested if statement example
- Java switch statement example
- Java if statement
- Java if-else statement
- Java if-else-if ladder statement
- Java if-then-else statement
- IF ELSE statement in a MySQL Statement?
- What is if...else if... statement in JavaScript?
- MySQL SELECT IF statement with OR?
- What is if statement in JavaScript?
- MySQL If statement with multiple conditions?
- C++17 If statement with initializer
- Java switch statement
- Java labelled statement
- Explain about single step income statement in accounting with example.
Advertisements