Inline front-end indentation
I noticed that when I inline implement the interface in the class itself, i.e. not inside a method,
Runnable r = new Runnable() {
@Override
public void run() {
// do something
}
};
and then press CTRL+ SHIFT+ F(auto-correct indentation), eclipse discards methods just like:
Runnable r = new Runnable() {
@Override
public void run() {
// do something
}
};
Has anyone else encountered this?
+3
source to share
3 answers
In eclipse preferences go to the formatting page (Window-> Preferences, Java-> Code Style-> Formatter). Edit the "Profile" formatting. Click the Blank Lines tab and change the Before First Declaration value from 1 to 0.
FYI, this will change the formatting for ALL classes, not just anonymous ones. It would be nice if it was more grainy, but it is.
+1
source to share