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 |
0 comments:
Post a Comment