Languages
[Edit]
EN

Java - how to cast Double object to primitive int?

11 points
Created by:
Frank-van-Puffelen
439

1. Problem description

Edit

How to cast Double object to primitive int type?

2. Solution with Double.intValue()

Edit

We can use Double.intValue() method as it returns primitive int.

Code example: 

Output:

3. Solution with casting

Edit
  1. Cast Double to primitive double
  2. Then cast primitive double to primitive int

Code example:

Output:

Merged questions

Edit
  1. Java - cast big Double to small integer
  2. Java - convert Double object to primitive int
  3. How to convert big Double to primitive int type in java?
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join