Follow @devglan
Write a Java Program to Print 1 To 10 Without Using Loop
Program Description
Write a java program to print 1 to 10 without using any loop.This can be achieved by using recursion in java.Following is the sample code.
package com.devglan.set2; public class Print { public static void printWithoutLoop(int n) { if (n <= 10) { System.out.println(n); printWithoutLoop(n + 1); } } public static void main(String[] args){ Print.printWithoutLoop(1); } }
Explanation
Click to Suggest Your Own Explanation
Other Similar Java Programs:
If You Appreciate This, You Can Consider:
- Share this article on social media or with your teammates.