(i += 1) is equivalent to i = i + 1
is it possible to have something like above by using multiplication like:
(i *= 1) , i = i * 1
I have try it by declare as double but I keep get 0.0 value in my result?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First declare
double i = 1.0;(orint i = 1;if no decimal values are needed.) It seems that you’re multiplying by zero. Of course, thenitimes1will always be1unless you’re modifying the value ofisomewhere else.Other than that, be aware that
i *= 1is almost equivalent toi = i * 1. The devil is in the details, as the first form will perform an implicit conversion as per the Java Language Specification, section §5.1.3: