Consider code like:
```
public class ConsoleTest {
public static void main(String... args) {
if (args.length > 0) {
System.out.println("Hello, World!");
} else {
System.console().printf("Hello, World!\n");
}
}
}
```
There is a significant difference in running time between the two variants, producing the following typical outputs:
---
# for console variant:
$ time java -classpath /tmp/ ConsoleTest
Hello, World!
real 0m0,169s
user 0m0,371s
sys 0m0,025s
# for System.out variants:
$ time ./build/linux-x86_64-server-release/images/jdk/bin/java -classpath /tmp/ ConsoleTest old
Hello, World!
real 0m0,033s
user 0m0,013s
sys 0m0,018s
---
Most of the difference appears to be a JLine initialization.
```
public class ConsoleTest {
public static void main(String... args) {
if (args.length > 0) {
System.out.println("Hello, World!");
} else {
System.console().printf("Hello, World!\n");
}
}
}
```
There is a significant difference in running time between the two variants, producing the following typical outputs:
---
# for console variant:
$ time java -classpath /tmp/ ConsoleTest
Hello, World!
real 0m0,169s
user 0m0,371s
sys 0m0,025s
# for System.out variants:
$ time ./build/linux-x86_64-server-release/images/jdk/bin/java -classpath /tmp/ ConsoleTest old
Hello, World!
real 0m0,033s
user 0m0,013s
sys 0m0,018s
---
Most of the difference appears to be a JLine initialization.