• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if else loop

 
suhem chauhan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using JBuilderX as an IDE.
There are few if else loop in my code the template is as below.
if(){
}
else if()
{
}
else if()
{
}

But the surprise is after writing the whole code when I did edit->format all

JBuilder changed it to

if(){
}
else(){
if(){
}
}
else(){
if(){
}}

so my question is, what is a good practice?

if- else if or simple if else loop.
Does performance affect as per what kind of loop are you using in your code?

Thanks in advance
Suhem
 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your IDE has got a particular indentation convention in its configuration files and it has re-formatted all your code to match that convention. Most people don't use { between else and if, but that file obviously has "always use {} after else" or similar in.

If-else isn't a loop. I don't think there is any performance difference between the two formats.
 
suhem chauhan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell,

Thanks a lot for your reply!

Suhem
 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic