Here is the integral test program that I came up (modified since the last posted answer above) with benchmark tests and all. I know there are faster implementations, and some optimizations can still be made, but here are some algorithms to generate prime numbers :

Enter N: 10000
Number of prime numbers found from 0 to 1000000 = 78498
The 10000th prime number is : 104729

With that in hand, you pretty have all that is to say about finding the nth prime number. For larger numbers (beyond int's), you'll have to modify the "default generator's" un-optimized method to accept long or use other methodologies (i.e. other language and/or libraries)

could help me by modifying my code so that i can see the changes..
–
jrdnsingh89Jan 13 '11 at 17:21

well, first, I'm not even sure what you're program is supposed to do... it inputs an int from the stdin, then creates an array of 1000 elements and fills it with values from 2 to 1000 (skipping indexes 0 and 1), then copy the elements from the array (including indexes 0 and 1... which are both == 0) into an ArrayList, removes the first two elements... sort it (??) then loop again over every elements and print any element which is is prime... why the first input? You want to print the prime from that input (nth)? If I have to change your code, I'd have to rewrite it all (sorry for the honesty)
–
Yanick RochonJan 14 '11 at 0:49

I am printing out a list of numbers from 2 to 1000 in a program and storing it an array. Then I want add those numbers to list using for each loop and then i check each number if its prime or not.. I want to then add all the prime #'s to list and get the prime on a particular index.. so lets say whts da first prime # its 2.. so at index 1 of the list there should be 2 and when i plugin in the value for n which is 1 the program should 2 as its the first prime #... you could go ahead and change the code..
–
jrdnsingh89Jan 14 '11 at 14:59

The code you have is pretty much the way to go, and Roflcopter's answer for picking the number is correct, but there is one optimization you could do that would significantly increase the performance. Instead of dividing by all numbers less than or equal to the square root, divide only by PRIMES less than or equal to the square root. Any number not divisible by any prime you've found so far is also not divisible by any combination of same, which is the definition of a nonprime number (having a prime factorization other than 1*N)