How to output the code itself? [duplicate]
Question
How many ways are there to let the code output itself?
For example, write the code below,
public class Test
{
public static void main(String[] args)
{
// some code
}
}
to output itself
public class Test
{
public static void main(String[] args)
{
// some code
}
}
(Any programming language is accepted)
EDIT This question has been answered in the historical posts, search "quine" or check out https://stackoverflow.com/search?q=quine
Solution
This is called a programming quine, and has been extensively discussed on SO:
https://stackoverflow.com/search?q=quine
Also see
http://en.wikipedia.org/wiki/Quine_(computing)
http://www.nyx.net/~gthompso/quine.htm
http://www.madore.org/~david/computers/quine.html
-Adam
OTHER TIPS
look up Quines.
You are wanting to read about quines. See here.
Hasn't this question already been asked?
There are an infinite number ways to do this. All you have to do is find one way and then add comments....