Been writing code since about 18 years now. Lately, I've got into the habit of not indenting elses and when I look at the code it does worry me a bit mostly that someone who might look at the code might cry foul.The snippet below explains the need for the styleif(condition) {   ...} //1 if(condition) { // Don't want this second block to be entered unnecessarily   ...}So I put an else where the comment labelled 1 isif(condition) {   ...} elseif(condition) {    ...}Putting an else there helps maintain readability especially when forgetting to put one there doesn't necessarily break anything. What I'm uneasy with is that it doesn't strictly follow conventions (Sun's in this case) in two different ways - 1) proper indentation 2) having an open brace after the elseI guess what I'm trying to do is prevent having massive indents which really makes a difference in blocks that have a lot of conditions - 5 or more although only three are showcased below. if(condition) {   ...} else {   if(condition) {       ...   } else {      if(condition) {          ...      } else {         ...      }   }}I find it a lot neater to have the else unindented and without a brace following. What are your thoughts?
Unindented elses
java;coding style
I usually see this solved by not putting the if inside a code block if it's the only statement in the else-part and  putting the if one the same line.This effectively emulates the elseif or elif of other languages.if (condition1) {  ...} else if (condition2) {  ...} else {  ...}This way there's no useless indentation and every code block has its braces, as it should be.I also never had any code quality tool nag at me for this, so I assume it's widely accepted.