java - Double to Number -


how convert double number in java, in code below?

public number parse(string text, parseposition status) {     // find best number (defined 1 longest parse)     int start = status.index;     int furthest = start;     double bestnumber = double.nan;     double tempnumber = 0.0;     (int = 0; < choiceformats.length; ++i) {         string tempstring = choiceformats[i];         if (misc.regionmatches(start, tempstring, 0, tempstring.length(), text)) {             status.index = start + tempstring.length();             tempnumber = choicelimits[i];             if (status.index > furthest) {                 furthest = status.index;                 bestnumber = tempnumber;                 if (furthest == text.length()) break;             }         }     }     status.index = furthest;     if (status.index == start) {         status.errorindex = furthest;     }     int c= 0;     return new double(bestnumber);  } 

but in eclipse shows

type mismatch: cannot convert double number 

actually code belongs choiceformat.java class java.text package.

java.lang.double subclass of java.lang.number. hence posted code shouldn't show compilation error if returning java.lang.double method returns java.lang.number .

as jon skeet pointed out, "you've got different double type or different number type somewhere". please double check see if using java.lang.double , java.lang.number.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -