wood burning stoves*
The moose likes IDEs, Version Control and other tools and the fly likes if else loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "if else loop" Watch "if else loop" New topic
Author

if else loop

suhem chauhan
Greenhorn

Joined: Jun 26, 2007
Posts: 14
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

Joined: Oct 13, 2005
Posts: 38107
    
  22
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

Joined: Jun 26, 2007
Posts: 14
Hi Campbell,

Thanks a lot for your reply!

Suhem
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: if else loop
 
Similar Threads
C# problem
equals compares the wrong things
�JavaScript to Java and back again� A developers adventure
Question about restart
Changing for loop into a while loop