+ 1
Indentation in java
Is indentation compulsory in java. As i am learning the if statement in java , I found that whether there is an indent or not, in the else statement the program works fine.
4 ответов
+ 3
No indentation is not nessesary, it's just there to make the code look more better and easily understandable.
+ 1
Java uses a blocks making by { } curly braces. There is no need Indentation .but adding Indentation will make code more readable..
0
Not compulsory. But it looks good when you use indentation.
1.
public void method()
{
if(condition)
{
System.out.print("if");
}
else{
System.out.print("else");
}
}
2.
public void method() {
if (condition) {
System.out.print("if");
} else {
System.out.print("else");
}
}
Which looks better?