import java.util.List ;
import java.util.ArrayList ;
import java.util.Arrays ;
class Hello {
public static int [ ] primesTo( int limit) {
boolean [ ] sieve = new boolean [ limit + 1 ] ;
for ( int p
= 3 ; p
<= Math .
sqrt ( limit
) ; p
+= 2 ) if ( sieve[ p] )
for ( int i = 3 ; i <= limit / p; i += 2 )
sieve[ p * i] = false ;
List< Integer> primes = new ArrayList< Integer> ( limit / 2 ) ;
primes.add ( 2 ) ;
for ( int i = 3 ; i <= limit; i += 2 )
if ( sieve[ i] )
primes.add ( i) ;
return ( int [ ] ) primes.toArray ( new int [ primes.size ( ) ] ) ;
}
}
aW1wb3J0IGphdmEudXRpbC5MaXN0OwppbXBvcnQgamF2YS51dGlsLkFycmF5TGlzdDsKaW1wb3J0IGphdmEudXRpbC5BcnJheXM7CiAKY2xhc3MgSGVsbG8gewogIHB1YmxpYyBzdGF0aWMgaW50W10gcHJpbWVzVG8oaW50IGxpbWl0KSB7CiAgICBib29sZWFuW10gc2lldmUgPSBuZXcgYm9vbGVhbltsaW1pdCArIDFdOwogICAgQXJyYXlzLmZpbGwoc2lldmUsIHRydWUpOwogCiAgICBmb3IoaW50IHAgPSAzOyBwIDw9IE1hdGguc3FydChsaW1pdCk7IHAgKz0gMikKICAgICAgaWYoc2lldmVbcF0pCiAgICAgICAgZm9yKGludCBpID0gMzsgaSA8PSBsaW1pdCAvIHA7IGkgKz0gMikKICAgICAgICAgIHNpZXZlW3AgKiBpXSA9IGZhbHNlOwogCiAgICBMaXN0PEludGVnZXI+IHByaW1lcyA9IG5ldyBBcnJheUxpc3Q8SW50ZWdlcj4obGltaXQgLyAyKTsKICAgIHByaW1lcy5hZGQoMik7CiAgICBmb3IoaW50IGkgPSAzOyBpIDw9IGxpbWl0OyBpICs9IDIpCiAgICAgIGlmKHNpZXZlW2ldKQogICAgICAgIHByaW1lcy5hZGQoaSk7CiAKICAgIHJldHVybiAoaW50W10pcHJpbWVzLnRvQXJyYXkobmV3IGludFtwcmltZXMuc2l6ZSgpXSk7CiAgfQp9
compilation info
Main.java:21: error: no suitable method found for toArray(int[])
return (int[])primes.toArray(new int[primes.size()]);
^
method List.<T>toArray(T[]) is not applicable
(inferred type does not conform to declared bound(s)
inferred: int
bound(s): Object)
method List.toArray() is not applicable
(actual and formal argument lists differ in length)
where T is a type-variable:
T extends Object declared in method <T>toArray(T[])
1 error
stdout