Instantly share code, notes, and snippets.

@benjholla /Quine.java Secret
Last active Aug 25, 2018

Embed
What would you like to do?
A simple quine using substring operations with an example runner script
/**
* This quine ignores whitespace and comments
* It could be run with the following bash script
*
* ----------------------------------------------
* #!/bin/bash
* while true; do
* rm -f Quine.class
* javac Quine.java
* rm -f Quine.java
* java Quine &> Quine.java
* done
* ----------------------------------------------
*
* @author Ben Holland
*/
public class Quine {
public static void main(String[] args) {
char quote = 34;
String code = "public class Quine { public static void main(String[] args) { char quote = 34; String code = ;System.out.print(code.substring(0,92) + quote + code + quote + code.substring(92,code.length())); } }";
System.out.print(code.substring(0,92) + quote + code + quote + code.substring(92,code.length()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment