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 353
programming x 169
Posted On : 2014-09-04 01:46:45.0
profile Saksham Kumar - anyforum.in Saksham Kumar
73433939909
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
523188250045
Reply This Thread
up-rate
5
down-rate



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