AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-programming: How to print the numbers from 0 to 100 without using for loop or recursion?

Please give me java source code to print the numbers from 0 to 100 without using for loop or recursion.

corejava x 352
programming x 168
Posted On : 2014-09-04 01:46:45.0
profile Saksham Kumar - anyforum.in Saksham Kumar
72933916624
up-rate
5
down-rate

Answers


There are many solutions available but all have either for loop or recursion. Following is the java source code to print the numbers without using for loop or recursion manually.


import java.util.*;
public class TimerUser
{
public static void main(String[] args)
{
new Timer().schedule(
new TimerTask()
{
int count;
public void run()
{
System.out.println(count+1);
if (++count >= 100)
System.exit(0);
}
},
new Date(), 1);
}
}

Posted On : 2014-09-04 01:58:48
Satisfied : 1 Yes  1 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188222140
Reply This Thread
up-rate
5
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in