how to print a numbers from 1 to 100 with out using control
structures?
Answer Posted / vinodh
public class Printnos
{
static int a[]=new int[100];
static int i=1;
public static void main(String args[])
{
try
{
i=add(i);
a[i]=i;
main(args);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println(i);
}
}
static int add(int i)
{
System.out.println(i);
return ++i;
}
}
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is an immutable class?
What is a function in java?
Why does java have two ways to create child threads?
Is integer immutable in java?
How do you avoid global variables?
Howto get an object that will perform date & time calculations then format it for output in some different locales with different date style.can ne1 tel me the answer of this question.pls
Can a final variable be null?
What is a for loop in java?
Why is method overloading not possible by changing the return type in java?
What is the java idl system?
Can we restart a dead thread in java?
What is main method?
How many types of the indexof method are there for strings?
What class allows you to read objects directly from a stream?
Explain the difference between intermediate and terminal operations in java8?