Print 1 to 10 without using loop in java

“Print 1 to 10 with out using loop” in java is quite a frequently asked interview question for automation testing.

simple answer is to use recursive method, where we can call method to increment the number till a particular number is achieved.

let’s see the implementation –

OutPut:

1
2
3
4
5
6
7
8
9
10

Content posted is based on learning or working experience, please leave comments if anything needs to be added or updated, discuss your queries on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: