How to remove decimal values from a value of type 'double' in Java

后端 未结 19 1924
孤独总比滥情好
孤独总比滥情好 2020-12-08 09:26

I am invoking a method called \"calculateStampDuty\", which will return the amount of stamp duty to be paid on a property. The percentage calculation works fine, and returns

19条回答
  •  感情败类
    2020-12-08 09:42

    With a cast. You're basically telling the compiler "I know that I'll lose information with this, but it's okay". And then you convert the casted integer into a string to display it.

    String newValue = ((int) percentageValue).toString();
    

提交回复
热议问题