Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Java 10, 2 quines, (削除) 1448 (削除ここまで) 1248 bytes

Java 10, 2 quines, (削除) 1448 (削除ここまで) 1248 bytes

#(削除) 1350 (削除ここまで) 1122 bytes

(削除) 1350 (削除ここまで) 1122 bytes

#126 bytes

126 bytes

#Java 10, 2 quines, (削除) 1448 (削除ここまで) 1248 bytes

#(削除) 1350 (削除ここまで) 1122 bytes

#126 bytes

Java 10, 2 quines, (削除) 1448 (削除ここまで) 1248 bytes

(削除) 1350 (削除ここまで) 1122 bytes

126 bytes

Fixed because I couldn't use `%1$c` due to the 1 in the second function.
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 10, 2 quines, (削除) 1448 (削除ここまで) 12301248 bytes

#108#126 bytes

v->{varint i='}'-'[';var s="v->{varint s=%c%s%1$c;Systemi='}'-'[';var s=%c%s%c;System.console().printf(s,'}'-'['i,s,i);}";System.console().printf(s,'}'-'['i,s,i);}

System.console() will return null when none is provided, so TIO returns a NullPointerException in this case TIO returns a NullPointerException in this case.

To prove it's a working quine, replace System.console() with System.out: Try it online. Try it online.

v->{ // Method with empty unused parameter and no return-type
 int i='}'-'['; // Integer `i` = 34 (unicode value for double-quote)
 var s="v->{varint s=%c%s%1$c;Systemi='}'-'[';var s=%c%s%c;System.console().printf(s,'}'-'['i,s,i);}";
 // Unformatted source code
 System.console().printf(s,'}'-'['i,s,i);}
 // Print formatted quine

Since the only way to have two quines in Java is using the unicode version with \uHEXA, which is converted to characters during compilation, I'm unable to use the characters 0123456789ABCDEF\u in the non-unicode version. So, the smaller non-unicode version will use System.console() instead of return or System.out (both containing a 'u'), and will use '}'-'[' and two times %c instead of 34 and %1$c.

#Java 10, 2 quines, (削除) 1448 (削除ここまで) 1230 bytes

#108 bytes

v->{var s="v->{var s=%c%s%1$c;System.console().printf(s,'}'-'[',s);}";System.console().printf(s,'}'-'[',s);}

System.console() will return null when none is provided, so TIO returns a NullPointerException in this case.

To prove it's a working quine, replace System.console() with System.out: Try it online.

v->{ // Method with empty unused parameter and no return-type
 var s="v->{var s=%c%s%1$c;System.console().printf(s,'}'-'[',s);}";
 // Unformatted source code
 System.console().printf(s,'}'-'[',s);}
 // Print formatted quine

Since the only way to have two quines in Java is using the unicode version with \uHEXA, which is converted to characters during compilation, I'm unable to use the characters 0123456789ABCDEF\u in the non-unicode version. So, the smaller non-unicode version will use System.console() instead of return or System.out (both containing a 'u'), and will use '}'-'[' instead of 34.

#Java 10, 2 quines, (削除) 1448 (削除ここまで) 1248 bytes

#126 bytes

v->{int i='}'-'[';var s="v->{int i='}'-'[';var s=%c%s%c;System.console().printf(s,i,s,i);}";System.console().printf(s,i,s,i);}

System.console() will return null when none is provided, so TIO returns a NullPointerException in this case.

To prove it's a working quine, replace System.console() with System.out: Try it online.

v->{ // Method with empty unused parameter and no return-type
 int i='}'-'['; // Integer `i` = 34 (unicode value for double-quote)
 var s="v->{int i='}'-'[';var s=%c%s%c;System.console().printf(s,i,s,i);}";
 // Unformatted source code
 System.console().printf(s,i,s,i);}
 // Print formatted quine

Since the only way to have two quines in Java is using the unicode version with \uHEXA, which is converted to characters during compilation, I'm unable to use the characters 0123456789ABCDEF\u in the non-unicode version. So, the smaller non-unicode version will use System.console() instead of return or System.out (both containing a 'u'), and will use '}'-'[' and two times %c instead of 34 and %1$c.

deleted 120 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

Try it online. Try it online.

v->{ // Method with empty unused parameter and no return-type
 var s="v->{var s=%c%s%1$c;System.console().printf(s,34'}'-'[',s);}";
 // Unformatted source code
 System.console().printf(s,'}'-'[',s);}
 // Print formatted quine

In which case the shortest base quine lambda-function in Java 10 would be this (82 bytes):

Try it online.

v->{ // Method with empty unused parameter and no return-type
 var s="v->{var s=%c%s%1$c;System.console().printf(s,34,s);}";
 // Unformatted source code
 System.console().printf(s,'}'-'[',s);}
 // Print formatted quine

In which case the shortest base quine lambda-function would be this (82 bytes):

Try it online.

v->{ // Method with empty unused parameter and no return-type
 var s="v->{var s=%c%s%1$c;System.console().printf(s,'}'-'[',s);}";
 // Unformatted source code
 System.console().printf(s,'}'-'[',s);}
 // Print formatted quine

In which case the shortest quine lambda-function in Java 10 would be this (82 bytes):

TIO wasn't updated yet..
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
added 1360 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading

AltStyle によって変換されたページ (->オリジナル) /