简体   繁体   中英

How do I convert a basic reference type variable to a primitive one?

I have two variables: Double x and double y . I would like to assign x's value to y, but obviously there is an "incompatible types" error that is shown in a simple y = x expression. y = (double) x does not work properly either. How can I solve this if it's generally possible?

您可以使用doubleValue()

double y = x.doubleValue();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM