Here are three small examples in Python3: # Example A. chr(39) == "'". a = 'a = {}{}{}; print(a.format(chr(39), a, chr(39)))'; print(a.format(chr(39), a, chr(39))) # Example B. chr(39) == "'". b = 'b = %s%s%s; print(b %% (chr(39), b, chr(39)))'; print(b % (chr(39), b, chr(39))) # Example C. %r will quote automatically. c = 'c = %r; print(c %% c)'; print(c % c)The following Java code demonstrates the basic structure of a quine. 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]); } } The source code contains a string array of itself, which is output twice, once inside quotation marks.
Here are three small examples in Python3 # Example A chr(39) == "'" a = 'a = {}{}{}; print(aformat(chr(39) a chr(39)))'; print(aformat(chr(39) a chr(39))) # Example B chr(39) == "'" b = 'b = %s%s%s; print(b %% (chr(39) b chr(39)))'; print(b % (chr(39) b chr(39))) # Example C %r will quote automatically c = 'c = %r; print(c %% c)'; print(c % c)The following Java code demonstrates the basic structure of a quine 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" " Systemoutprintln(l[i]);" " for (int i = 0; i < llength; i++) // Print string array" " Systemoutprintln(l[6] + q + l[i] + q + '');" " for (int i = 7; i < llength; i++) // Print this code" " Systemoutprintln(l[i]);" " }" "}" }; for (int i = 0; i < 6; i++) // Print opening code Systemoutprintln(l[i]); for (int i = 0; i < llength; i++) // Print string array Systemoutprintln(l[6] + q + l[i] + q + ''); for (int i = 7; i < llength; i++) // Print this code Systemoutprintln(l[i]); } } The source code contains a string array of itself which is output twice once inside quotation marks