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

What is string pool in java?

1036


How do you create immutable object in java?

1067


What do you understand by access specifiers in Java?

1028


Can interface be private in java?

1040


How to retrieve data from database in java using arraylist?

1064


Is it possible to write a regular expression to check if string is a number?

1041


What is null mean in java?

1110


Can main() method in java can return any data?

1196


What is the purpose of a volatile variable?

1078


Is passing by reference faster?

1007


What is fail first in java?

1219


What's the purpose of static methods and static variables?

1107


What is an off by one error in java?

974


what do you mean by stream pipelining in java 8? Explain

1038


Explain the transient field modifier?

1060