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 a vector in java?

580


Is string a class in java?

517


Why are parameters used in functions?

534


Will set allow duplicates in java?

509


What is an anonymous class in java?

554






When will we use them?

601


What is the size of string?

568


Can a final variable be initialized in constructor?

492


What is the relationship between clipping and repainting under awt?

623


Why pass by reference is not possible in java?

502


What is a get method?

539


How to remove the trailing spaces from a string?

658


When is the finally clause of a try-catch-finally statement executed?

510


What are the four versions of java?

556


What is the purpose of default constructor?

586