Hello i am trying to write a program to find all the prime numbers in a given number range but i cant seem to do it. Here is what i have so far, i think im close but just cant get it right

Code:

public class MainClass

{

public static ArrayList<Integer> interval( int m, int n )

{

ArrayList<Integer> result = new ArrayList<Integer>();

int a= m-1;

for(int i = m; i<=n; i++ )

{

a++;

result.add(a);

}

return result;

}

public static boolean divides( Integer a, Integer b )

{

return ((b % a) == 0);

}

public static ArrayList<Integer> primes( int t )

{

ArrayList<Integer> plist = interval( 2, t );

int m = 0;

while ( m < plist.size() )

{

int n = m;

while ( n < plist.size() )

{

if ( divides( plist.get( m ), plist.get( n ) ) )

plist.remove( n );

else

n++;

}

m++;

}

return plist;

}

public static void main( String[] args )

{

System.out.println( primes( 20 ) );

}