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

Define array. Tell me about 2-D array.

584


What is int short for?

512


what is the difference between the methods sleep() and wait()? : Java thread

515


Why is it called boolean?

521


Explain working of call by reference function invoking.

585






What is a static method in java?

535


Can java list contain duplicates?

574


What are the disadvantages of object oriented programming?

588


Why is it important to initialize a variable?

489


How can we avoid including a header more than once?

608


What is the difference between replace and replace all?

470


What is parsing in java?

527


Define a java class.

803


What is array class in java?

592


What is time complexity java?

532