For example, say the following code appears in your editor as:
import java.util.*; public final class TabsOne { void decideWhatToDo(){ if(! bored){ continueWhatYourAreDoing(); } else { if (! hasCarpalTunnelIssues()) { code(); } else { eatSomething(); } } } }If you are using TAB characters, then this could easily appear in another tool as:
import java.util.*; public final class TabsTwo { void decideWhatToDo(){ if(!bored){ continueWhatYourAreDoing(); } else { if (! hasCarpalTunnelIssues()) { code(); } else { eatSomething(); } } } }
Even worse, some tools can even render text with TABs with negative indentation:
import java.util.*; public final class TabsThree { void decideWhatToDo(){ if(!bored){ continueWhatYourAreDoing(); } else { if (! hasCarpalTunnelIssues()) { code(); } else { eatSomething(); } } } }Most people would consider such code as much more difficult to read, and annoying. Thus, using TAB characters in source code is often considered highly undesirable.
You should use 2-4 spaces to indent your code, not TAB characters. Modern IDE's let you map TAB keystrokes to a given number of spaces instead.
Here's a related quote from Code Complete, by Steve McConnell:
"The study concluded that two-to-four-space indentation was optimal. Interestingly, many subjects in the experiment felt that the six-space indentation was easier to use than the smaller indentations, even though their scores were lower. That's probably because six spaces looks pleasing. But regardless of how pretty it looks, six-space indentation turns out to be less readable. This is an example of a collision between aesthetic appeal and readability."