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

Give me example of derived data types.

838


What is a java predicate?

723


Explain how can you debug the Java code?

821


What is the difference between assignment and initialization?

788


What is return null in java?

699


Difference between arraylist and hashset in java?

769


What is a buffer in java?

770


how would you implement a thread pool? : Java thread

677


How do you use compareto in java?

738


What is the meaning of variable in research?

765


What is difference between iterator and enumeration in java?

734


what is static import in java? Explain

773


String class is defined under which package in java?

808


What is broken and continue statement?

733


What do you mean by an interface in java?

758