How to save decimal in java
Initialize your variable with an expression that evaluates to a double rather than an int: Otherwise the expression is done using integer arithmetic (which ends up truncating the result). That truncated result then gets converted to a double.