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 string pool in java?
How do you create immutable object in java?
What do you understand by access specifiers in Java?
Can interface be private in java?
How to retrieve data from database in java using arraylist?
Is it possible to write a regular expression to check if string is a number?
What is null mean in java?
Can main() method in java can return any data?
What is the purpose of a volatile variable?
Is passing by reference faster?
What is fail first in java?
What's the purpose of static methods and static variables?
What is an off by one error in java?
what do you mean by stream pipelining in java 8? Explain
Explain the transient field modifier?