how to print a numbers from 1 to 100 with out using control
structures?

Answer Posted / sushila

public class Arr
{
static int a[]=new int[100];
static int i=0;
public static void main(String args[])
{
try
{
i=add(i);
a[i]=i;
main(args);
}
catch(ArrayIndexOutOfBoundsException e){

}
}
static int add(int i)
{
System.out.println(++i);
return ++i;
}
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a vector in java?

580


What are multiple inheritances?

589


What is thread pool? How can we create thread pool in java?

631


Can static method access instance variables ?

609


How does the garbage collector works in java?

574






What is the this keyword?

560


What does += mean coding?

517


What is the purpose of tostring() method in java?

560


What is the function of http?

539


What are examples of modifiers?

518


What is constructor chaining and how is it achieved in java?

578


What is meant by binding in rmi?

556


Can a variable be local and static at the same time?

549


How many boolean functions are there?

513


What is java util hashmap?

528