If Statement

if(boolean){
	//body of If
}
//Outside of the if body..

Here, if is a keyword. In the above statement boolean is a boolean value. So if statement takes a boolean value. If the boolean value is true then, the body of if gets executed. And if the value is false then, the body of if is skipped and control is passed over to the outside of the if body. This concept is pretty simple. Sometimes you want to execute one or more statement depending on a conditioin and if statement does so.

Here, the body of if can contain one or more statment. There's no limit on how many statement you can use inside the body. It's unlimited. You can write any statement you want. But, you can't define functions, classes, interface inside the body of if. Though some programming language allow you to do that. But in most programming language it is forbidden.

If there's only one statement to be executed inside the body of the if, I mean, if there's only one statement inside the if body, you can omit the curly bracket gracefully. And the code will look simpler.

if(boolean)
	//body of If
//Outside of the if body..

If the boolean value is true, and there's no curly bracket, the statement will look for a single statement that is immediately after the if statement and execute it. Similar way, if the value is false, then the statement immediately after if, will be skipped.

But, in real life situation, we always want to execute if body depending on a value, not just predefined true and false keyword. So, the syntax would be more like -

	if(condition)
		Statement;
	//Outside of the if body..

Here, condition may be any expression, or function call that returns value, or the keyword true or false. But whatever you use, it must be evaluated to boolean value. For example, if you use an expression, the value must be evaluated to either true or false.

In most programming language, implicit conversion happens. For example, if the expression returns an integer value, the language will convert the integer value automatically to boolean value. The common rules is that if the value is 0, the corresponding boolean value would be false. If the value is anything but 0, the corresponding value would be true.

For, string data type, empty string treated as false whereas the string contains at least one character considered as a true value.

	if(""){
		// The body will never be executed.
	}

If you use, null, some language will throw an error, and some language will treat this value as a false.

	if(null){
		// The body will never be executed.
	}

The the point is, whatever value you use inside the if statement, it doesn't matter. The only thing matter that the boolean value that it is converted into. If statement doesn't care about anyvalue other than true and false. If the value is true it will execute the body and if the value is false the body will never execute.