# simple java calculation

• October 12th, 2013, 11:39 AM
dulitul
simple java calculation
Hello guys,

I am currently learning Java. Excuse me for my stupid question. I have come across an example in my book which I don't quite understand. Can anyone explain me please?

K has the value 10 and j == 5
It says that the following expression should equal: k==0; j==4;. The expression is:

k/= 25 * j--

I think though that k==10 and j==4 because - we do the following:

k/= 25 * (j=j-1)

k/= 25 * 4

k/= 100

k= k/100

k= 10

As a result k==10 and j==4. Can anyone clarify please?

Thank you
• October 12th, 2013, 12:03 PM
GregBrannon
Re: simple java calculation
I assume k and j are ints.

What is the result of any int divided by a larger int?
• October 12th, 2013, 12:09 PM
dulitul
Re: simple java calculation
int / int = int

100:10 = 10 and not 0. This is the way I get it. Could you please clarify what do you exactly mean?
• October 12th, 2013, 12:13 PM
GregBrannon
Re: simple java calculation
An int divided by a larger int, as in:

int k = 10 / 100;

What will k be?
• October 12th, 2013, 12:17 PM
dulitul
Re: simple java calculation
ohhh..right..now I got it. How stupid..it will be 0. It will be 10: 100 and not 100:10.