Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java division: Inconvertible types found: int

What's wrong with this code

int numOfPrimes=pf.FindNumPrimes(10000);
Double frequency=((Double)numOfPrimes)/10000d;

Says

inconvertible types found : int required: java.lang.Double Double frequency=((Double)numOfPrimes)/10000d;

like image 348
Madhur Ahuja Avatar asked Aug 15 '26 12:08

Madhur Ahuja


1 Answers

You're trying to autobox an int to a Double object, which is invalid.

Try:

int numOfPrimes=pf.FindNumPrimes(10000);

Double frequency=((double)numOfPrimes)/10000d;
like image 51
MRalwasser Avatar answered Aug 17 '26 02:08

MRalwasser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!