-1

Can anyone tell me how to write a java program that print itself without using file IO. I googled a lot, but I can't find the exact answer. I found some useful tips here . Is there any way to write self print program without using file IO ?

Community
  • 1
  • 1
Saravanan
  • 67
  • 2
  • 11

1 Answers1

-1

Here you can find many implementations, the first by Bertram Felgenhauer follows:

class S{public static void main(String[]a){String s="class S{public static void main(String[]a){String s=;char c=34;System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}}";char c=34;System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}}

By the way, this is known as a quine, a program whose output is itself.

frhack
  • 4,862
  • 2
  • 28
  • 25
xrisk
  • 3,790
  • 22
  • 45