How to save decimal in java

Initialize your variable with an expression that evaluates to a double rather than an int:

double operation = 890.0 / 1440.0;

Otherwise the expression is done using integer arithmetic (which ends up truncating the result). That truncated result then gets converted to a double.

Leave a Comment