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 a vector in java?
Is string a class in java?
Why are parameters used in functions?
Will set allow duplicates in java?
What is an anonymous class in java?
When will we use them?
What is the size of string?
Can a final variable be initialized in constructor?
What is the relationship between clipping and repainting under awt?
Why pass by reference is not possible in java?
What is a get method?
How to remove the trailing spaces from a string?
When is the finally clause of a try-catch-finally statement executed?
What are the four versions of java?
What is the purpose of default constructor?