6

Possible Duplicate:
Order of execution of parameters guarantees in Java?

If I have a Java method like:

    public void func(byte b, byte c) {...}

And I use it like this:

    a = 0;
    func(a++, a);

Wich parameter is passed first? Because if i'm not wrong, if it's the left one then b = 0 and c = 1. And if it's the right one then b = 0 and c = 0?

Thank you.

Community
  • 1
  • 1
0x77D
  • 1,564
  • 2
  • 18
  • 17
  • 1
    I think it's an interesting question, but the benefit is near zero. I'd not recommend writing code like this, because it's highly unclear – otherwise you wouldn't have asked. But it shouldn't be that hard to find a solution. – Koraktor Feb 14 '12 at 23:11
  • 5
    1) I would not want to see this code in production. 2) Test it. Then you'll know. – Anthony Pegram Feb 14 '12 at 23:11
  • 2
    It's not "passed first", it's "evaluated when". They're passed at the same "time". – Dave Newton Feb 14 '12 at 23:13
  • Thank you all for your comments, it was just an existential question :P – 0x77D Feb 14 '12 at 23:26

1 Answers1

10

The arguments are evaluated left to right, as specified in the JLS - section 15.7.4.

jchamp
  • 172
  • 3
  • 11
MByD
  • 135,866
  • 28
  • 264
  • 277