| Author |
java code on as a output
|
naveen yadav
Ranch Hand
Joined: Oct 23, 2011
Posts: 380
|
|
hi ranchers,
Is that possible to write a java source program that print itself as output ??
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 10040
|
|
|
yes
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Keith Rainey
Ranch Hand
Joined: Jan 19, 2011
Posts: 66
|
|
|
Read this thread: here
|
Keith Rainey
OCPJP6
|
 |
naveen yadav
Ranch Hand
Joined: Oct 23, 2011
Posts: 380
|
|
hi fred rosenberger ,
i follow your link but the following store itself in string array and then print itself through in loop.this i was looking for some robust method.
by the way thanks .
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 10040
|
|
it doesn't quite store itself, as that would be infinitely recursive - it stores a sub-set of itself.
What do you mean by a 'robust method'? What are you actually trying do do? It would be much easier if you told us what you really want, rather than ask a vague question and then tell me my answer isn't what you were looking for.
|
 |
naveen yadav
Ranch Hand
Joined: Oct 23, 2011
Posts: 380
|
|
what i want is write a simple java program and using Java API or some other way (Robust way) to print the program code itself.
note that in the program should print itself i without any duplication code. as it was in above example.
|
 |
Saifuddin Merchant
Ranch Hand
Joined: Feb 08, 2009
Posts: 576
|
|
|
Have a look at the link Keith Rainey has posted - it gives you hints how to do that!
|
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
|
 |
Saifuddin Merchant
Ranch Hand
Joined: Feb 08, 2009
Posts: 576
|
|
and here a link which writes Quine in all possible languages,
http://www.nyx.net/~gthompso/quine.htm
There are about 4 or 5 real java solutions too!
|
 |
naveen yadav
Ranch Hand
Joined: Oct 23, 2011
Posts: 380
|
|
hi Sam Mercs,
i follow your link nothing new was there were same examples which uses string array and duplicate the source code
Although the link provided by Keith Rainey is good in-comparison
|
 |
 |
|
|
subject: java code on as a output
|
|
|