Print 1 to 10 numbers without loop in Java

This is simple java program to write 1 to 100 counting without loop in java. Recursive function is used to perform this task. Recursive function calls itself again and again to print 1 to 10 numbers.

Source Code 





public class recursionfun {

public static void main(String[] args) {
System.out.print("\t \t \t LEP Tutorials \n \n ");
int a = 1;
start(a);
}
public static void start (int s)
{
if (s<=10)
{
System.out.print(" \n " + s);
start(s+1);
}
}
}

Output of the Program

Print 1 to 10 Number without Loop in Java
Print 1 to 10 Number without Loop in Java


Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment