coder-coder
coder-coder

Reputation: 353

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?

Upvotes: 0

Views: 45

Answers (1)

Guy
Guy

Reputation: 50809

You can use doubleValue()

double y = x.doubleValue();

Upvotes: 1

Related Questions