Last active
December 8, 2020 08:02
-
-
Save destan/c0db5a237e9875a56141403aaa6cb9c7 to your computer and use it in GitHub Desktop.
Simple Java quine, self replicating (self copying) Java code, with text blocks. This code can be run with Java 15+ or Java 13+ with special flags. License is public domain, no rights reserved.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Quine { | |
public static void main(String[] args) { | |
String textBlockQuotes = new String(new char[]{'"', '"', '"'}); | |
char newLine = 10; | |
String source = """ | |
public class Quine { | |
public static void main(String[] args) { | |
String textBlockQuotes = new String(new char[]{'"', '"', '"'}); | |
char newLine = 10; | |
String source = %s; | |
System.out.println(source.formatted(textBlockQuotes + newLine + source + textBlockQuotes)); | |
} | |
} | |
"""; | |
System.out.println(source.formatted(textBlockQuotes + newLine + source + textBlockQuotes)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment