This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Need Help: Recursive Code -- > Loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need Help: Recursive Code -- > Loop" Watch "Need Help: Recursive Code -- > Loop" New topic
Author

Need Help: Recursive Code -- > Loop

Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
Hello,

I'm having problems with following code segments....
'trying to make loop out of the first part...but something seems to be going wrong.

can anyone see my mistake.....?

thanks.
___________________________________________________________________



[ April 10, 2006: Message edited by: Wolfgang Obi ]

[ April 10, 2006: Message edited by: Wolfgang Obi ]
[ April 10, 2006: Message edited by: Wolfgang Obi ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

What does the schritt01 method do? It's not defined in the posted code.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Oh, I think I see. These methods are supposed to give a binary representation of the input int, right? And schritt01 basically concatenates a char to the output.

If you add the following test code...

...and then run with a command line argument (for example, 1234567), you will see that recu03 does give the correct binary representation. However, iter03 is in reverse order and missing a digit.

H:\Java>java Tester 1234567
100101101011010000111
100101101011010000111
11000010110101101001 <== REVERSED AND MISSING DIGIT

That should suggest where the problem is.
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
thanks Marc!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need Help: Recursive Code -- > Loop