Would it be possible to write a quine (a program whose output is itself) in Java using the Reflection API to access the quine's code and then print it out? Such a program would still print itself out accurately even when random lines that have no effect on the output are added.
Asked
Active
Viewed 203 times
1 Answers
1
I don't think so. The reflection api doesn't provide access to the actual source code, but only to class and member definitions.

aditsu quit because SE is EVIL
- 4,019
- 1
- 34
- 48
-
https://en.wikipedia.org/wiki/Quine_%28computing%29 shows how to write such programs called "quines" in a variety of languages including Java. There is also The Quine Page that contains examples in many more languages: http://www.nyx.net/~gthompso/quine.htm – Kim Mens Apr 14 '22 at 19:54