public class Primes { public static void main(String[] args) { final int MAX = 200; boolean[] primes = new boolean[MAX]; fillPrimes(primes); computePrimes(primes); displayPrimes(primes); } public static void fillPrimes(boolean[] myPrimes) { for(int i = 0;i < myPrimes.length;i++) { myPrimes [i] = true; } } public static void computePrimes(boolean[] myPrimes) { for(int i = 2;i<myPrimes.length; i++) { if(myPrimes[i]) { for (int j = i+1;j<myPrimes.length;j++) { if(j%i==0) { myPrimes[j] = false; } } } } } public static void displayPrimes(boolean[] myPrimes) { for(int i = 2;i < myPrimes.length;i++) { if(myPrimes[i]==true) { System.out.print(i + ", "); /**(myPrimes[i]+ ",");**/ } } } }

The only problem is that after the last number prints another comma prints after it. How do I get ride of the last comma? Please help, thanks in advance