In Section 4.6.1 Vertical whitespace, the Style Guide allows multiple consecutive blank lines and google-java-formatter removes consecutive blank lines during formatting, as shown below.
Multiple consecutive blank lines are permitted, but never required (or encouraged).
Formatter
$ java -jar google-java-format-1.33.0-all-deps.jar Test.java > FormattedCode.java
$ diff -Naru Test.java FormattedCode.java
--- Test.java 2025-12-29 21:28:43.899070500 +0530
+++ FormattedCode.java 2025-12-29 21:31:15.540657300 +0530
@@ -4,41 +4,28 @@
/** Test. */
public class Test {
-
+
static int count;
String str;
{
str = "Hello";
-
-
-
-
}
Test() {
int a;
-
int b;
-
-
}
static {
-
-
count = 5;
-
-
-
}
/** Method. */
public void foo() {
int x = 10;
-
int y = 20;
}
@@ -46,5 +33,4 @@
public static void main(String[] args) {
new Test();
}
-
-}
\ No newline at end of file
+}
Could you please confirm whether this behavior is intentional or a bug?