

- 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
An if statement consists of a Boolean expression followed by one or more statements.
Syntax
Following is the syntax of an if statement −
if(Boolean_expression) { // Statements will execute if the Boolean expression is true }
If the Boolean expression evaluates to true then the block of code inside the if statement will be executed. If not, the first set of code after the end of the if statement (after the closing curly brace) will be executed.
Flow Diagram
Example
public class Test { public static void main(String args[]) { int x = 10; if( x < 20 ) { System.out.print("This is if statement"); } } }
This will produce the following result −
Output
This is if statement.
- Related Questions & Answers
- Java if-else statement
- Java if statement example
- Java if-else-if ladder statement
- Java if-then-else statement
- Java nested if statement example
- IF ELSE statement in a MySQL Statement?
- What is if...else if... statement in JavaScript?
- What is if statement in JavaScript?
- MySQL SELECT IF statement with OR?
- MySQL If statement with multiple conditions?
- C++17 If statement with initializer
- Java switch statement
- Java labelled statement
- Which is faster, a MySQL CASE statement or a PHP if statement?
- IF() function in a MySQL Select statement?
Advertisements