Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

How to split arraylist elements in java?

1234


What is Applet Stub Interface ?

2568


What are the advantages of java over C++?

1254


How to sort array in descending order in java?

966


Can you sort a string in java?

977


Explain the difference between abstraction and encapsulation.

1035


Can we override final method?

1071


What is size_t?

1037


Explain the private protected method modifier?

1032


Do loops java?

1071


What are heterogeneous objects?

1087


What is the use of arraylist class in java?

1131


What is a literal coding?

1069


State the significance of public, private, protected class?

1165


What is an enumeration?

1121