I taught myself Java and for reasons I can’t remember I’ve always written brackets as
void method()
{
if(true)
{
//code
}
else
{
//code
}
}
When all the examples I see are
void method(){
if(true){
//code
}else{
//code
}
}
Does anyone know of the reason it’s done like it is and is there any reason to change the way I write it? I think it’s easier to read.
This is one of those “there is no right answer”
The way you indent your code is called the Allman Style
While the other style is Kernel Normal Form (KNF)