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


Please Help Members By Posting Answers For Below Questions

What is an immutable class?

614


What is a function in java?

570


Why does java have two ways to create child threads?

464


Is integer immutable in java?

549


How do you avoid global variables?

541






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

1446


Can a final variable be null?

545


What is a for loop in java?

597


Why is method overloading not possible by changing the return type in java?

590


What is the java idl system?

583


Can we restart a dead thread in java?

552


What is main method?

535


How many types of the indexof method are there for strings?

489


What class allows you to read objects directly from a stream?

870


Explain the difference between intermediate and terminal operations in java8?

568