This content has been marked as final. Show 2 replies
The keyword is <i>recursion</i>.
Collect the numbers given by the user in a List.
Call a method which takes the list a parameter.
in that Method write out the first element of the List (with <tt>System.out.print()</tt> to avoid newline).
if the list containes more than one element create a new List without the first element and call the method again with the new shorter list.
If the list has only one element left write out a newline and return.
Thank you for the reply, I got a feeling recursion would be the answer but I can't say I always fully understand it. I think I see what you are getting at and I'm going to try and get my head around it and see how it goes.
I''m going to try and create another small example before implementing it in my main code as the actual problem is more complicated than that but I get the feeling the principle will be the same.