Skip to content

Instantly share code, notes, and snippets.

@Acarus
Created April 26, 2017 21:01
Show Gist options
  • Save Acarus/1a13af1ff0f621c2093c2ae4483c5b22 to your computer and use it in GitHub Desktop.
Save Acarus/1a13af1ff0f621c2093c2ae4483c5b22 to your computer and use it in GitHub Desktop.
public class Quine
{
public static void main(String[] args)
{
char q = 34; // Quotation mark character
String[] l = { // Array of source code
"public class Quine",
"{",
" public static void main(String[] args)",
" {",
" char q = 34; // Quotation mark character",
" String[] l = { // Array of source code",
" ",
" };",
" for(int i = 0; i < 6; i++) // Print opening code",
" System.out.println(l[i]);",
" for(int i = 0; i < l.length; i++) // Print string array",
" System.out.println(l[6] + q + l[i] + q + ',');",
" for(int i = 7; i < l.length; i++) // Print this code",
" System.out.println(l[i]);",
" }",
"}",
};
for(int i = 0; i < 6; i++) // Print opening code
System.out.println(l[i]);
for(int i = 0; i < l.length; i++) // Print string array
System.out.println(l[6] + q + l[i] + q + ',');
for(int i = 7; i < l.length; i++) // Print this code
System.out.println(l[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment