Skip to content

1fxe/Quine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quine

Simple Java Quine using String Literals

A quine is a self-referential program that can, without any external access, output its own source. Definition

Running

Quine …
➜ java src/Quine.java > Quine2.java &&
➜ diff -s -q src/Quine.java Quine2.java
Files src/Quine.java and Quine2.java are identical

Shortest

This is the shortest Quine I could make

enum Q{U;{var s="enum Q{U;{var s=%c%s%1$c;System.out.printf(s,34,s);System.exit(0);}}";System.out.printf(s,34,s);System.exit(0);}}

It abuses Java class loading

$ java Main.java > Main2.java && diff Main.java Main2.java -s
Files Main.java and Main2.java are identical