Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java code on as a output

 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers,


Is that possible to write a java source program that print itself as output ??
 
fred rosenberger
lowercase baba
Bartender
Posts: 12122
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Keith Rainey
Ranch Hand
Posts: 66
Android Eclipse IDE IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this thread: here
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12122
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the link Keith Rainey has posted - it gives you hints how to do that!
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic