2

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.

APerson
  • 8,140
  • 8
  • 35
  • 49

1 Answers1

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.

  • 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