Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: simple java calculation

1. ## 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  Reply With Quote

3. ## Re: simple java calculation

I assume k and j are ints.

What is the result of any int divided by a larger int?  Reply With Quote

4. ## 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?  Reply With Quote

5. ## Re: simple java calculation

An int divided by a larger int, as in:

int k = 10 / 100;

What will k be?  Reply With Quote

6. ## 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.

How about expressions like

m = j++ + k. Can you tell me what will be the precedence order and the result given that m = 10, j=3 and k=2  Reply With Quote

7. ## Re: simple java calculation

So that you know how to find these things yourself, try searching for 'java precedence' with your favorite search engine. The top 2 results I got from Google are both excellent.  Reply With Quote