Skip to main content
deleted 318 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java[1] 5, 61 bytes

This is valid in both Java 5 and Java 6. This won't work in Java 4 or earlier (because enum didn't exist) and will not work in Java 7 or after (because thethis solution uses a bypass[2][1] that was "fixed").

  1. As of today, this is still the shortest Java answer in all versions of the language. So this is why it's not named "Java 5 & 6" or equivalent. When shorter answers will come up (and they will come up because some JEPs intend to shorten what it means to be a Java program), then only it will be relevant to say Java 5 & 6.

  2. The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.

    The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.

Java[1], 61 bytes

This is valid in both Java 5 and Java 6. This won't work in Java 4 or earlier (because enum didn't exist) and will not work in Java 7 or after (because the bypass[2] was "fixed").

  1. As of today, this is still the shortest Java answer in all versions of the language. So this is why it's not named "Java 5 & 6" or equivalent. When shorter answers will come up (and they will come up because some JEPs intend to shorten what it means to be a Java program), then only it will be relevant to say Java 5 & 6.

  2. The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.

Java 5, 61 bytes

This is valid in both Java 5 and Java 6. This won't work in Java 4 or earlier (because enum didn't exist) and will not work in Java 7 or after (because this solution uses a bypass[1] that was "fixed").

  1. The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.
added 342 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java[1], 61 bytes

This is valid in both Java 5 and Java 6. This won't work in Java 4 or earlier (because enum didn't exist) and will not work in Java 7 or after (because the bypass[1][2] was "fixed").

1: The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.

  1. As of today, this is still the shortest Java answer in all versions of the language. So this is why it's not named "Java 5 & 6" or equivalent. When shorter answers will come up (and they will come up because some JEPs intend to shorten what it means to be a Java program), then only it will be relevant to say Java 5 & 6.

  2. The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.

Java, 61 bytes

This is valid in both Java 5 and Java 6. This won't work in Java 4 or earlier (because enum didn't exist) and will not work in Java 7 or after (because the bypass[1] was "fixed").

1: The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.

Java[1], 61 bytes

This is valid in both Java 5 and Java 6. This won't work in Java 4 or earlier (because enum didn't exist) and will not work in Java 7 or after (because the bypass[2] was "fixed").

  1. As of today, this is still the shortest Java answer in all versions of the language. So this is why it's not named "Java 5 & 6" or equivalent. When shorter answers will come up (and they will come up because some JEPs intend to shorten what it means to be a Java program), then only it will be relevant to say Java 5 & 6.

  2. The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.

Rollback to Revision 12 - Edit approval overridden by post owner or moderator
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java 5 & 6, 61 bytes

Java 5 & 6, 61 bytes

Java, 61 bytes

Fix size, which is 61 bytes and not 62 bytes.
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 96 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
Yup, I tested it on Java 5! I finally took the time to install it ;-)
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 291 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 141 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 141 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 5 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 5 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 96 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 55 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
Forgot the comma.
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading