doubleValue() Correct use?

im trying to use doubleValue method,but not sure how to do so correctly.Passing in array of double's and need to get value,as in method below

public boolean priceChecker( Double[] playerValue)

{

boolean allOk = true;

double totalScore = 0;

for ( int i = 0; i < playerValue.length; i++ ) {

totalScore += playerValue.doubleValue(); //cannot find symbol doubleValue()

}

if (totalScore > 40)

{

allOk = false;

}

else{

allOk = true;

}

return allOk;

}

i have imported import java.lang.Number.*; whci from API i think it extends from..what is the problem.Is this a legal way of using it?

Regards,

Styx21

[723 byte] By [Styx218a] at [2007-11-27 4:06:34]
# 1
playerValue // arrayplayerValue[0] // DoubledoubleValue() is a method of Double, not Array. what you need should beplayerValue[i].doubleValue();
rym82a at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...
# 2
That did it thanks rym82 :)One more quick qI want to call method from another method within same class as suchif(priceChecker(Double[] playerValue)= true){try{......}Which is legal way to do this?10 duke stars awarded to you
Styx218a at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...
# 3
Number is an abstract so you can't use that...What you need to do is change playerValue.doubleValue() to playerValue.doubleValue()Edit: Sorry, spent too long on the post page :)Message was edited by: nogoodatcoding
nogoodatcodinga at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...
# 4

if(priceChecker(Double[] playerValue)= true)

{

try

{......

}

Don't see why not, but you should either change it to:

if(priceChecker(Double[] playerValue) == true) //== is the comparison operator, = is assignment

or just

if( priceChecker(Double[] playerValue) ) //don't need to explicitly equate to true or false if returning boolean

nogoodatcodinga at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...
# 5
Yes i had it like that but getting '.class expected'..
Styx218a at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...
# 6

> That did it thanks rym82 :)

>

> One more quick q

>

> I want to call method from another method within same

> class as such

>

> if(priceChecker(Double[] playerValue)= true)

>{

>try

>{......

>

> Which is legal way to do this?

>

> 10 duke stars awarded to you :)

if(priceChecker(Double[] playerValue)= true) // compile error, use == for comparison, use = for assignment

// also you don't declare the data type when calling a method

Double[] playerValue;

// do something to initialize and assign value to your Double array

if(priceChecker(playerValue) == true) // can compile now

if(priceChecker(playerValue)) // even better

if(!isPriceOverLimit(playerValue)) // even better (naming convention, meaningful name)

if(!isPriceOverLimit(playerValue)) { // Legal and has no problem

try {

// do something

} catch (Exception e) {

// catch exception

}

}

rym82a at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...
# 7
Yes that did it..i initialized double within the methodDouble[] playerValue = new Double[10];if( priceChecker(playerValue)){}try {.....catch{....
Styx218a at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...
# 8
oh and many thanks for your time ;)
Styx218a at 2007-7-12 9:11:43 > top of Java-index,Java Essentials,New To Java...