Created
April 25, 2013 14:30
-
-
Save ybonnel/5460138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void testCalcul1() { | |
| int i; | |
| // Compile pas, on ne peux pas faire un '++' sur un int non-initialisé. | |
| i = i++; | |
| System.out.println(i); | |
| } | |
| @Test | |
| public void testCalcul2() { | |
| int i = 0; | |
| // 0 je pense le ++ est fait après la récup de valeur mais avant l'affectation. | |
| i = i++; | |
| System.out.println(i); | |
| } | |
| @Test | |
| public void testCalcul3() { | |
| int i = 1; | |
| // 2 je pense le ++ est fait après la récup de valeur mais avant l'affectation. | |
| i = 1 + i++; | |
| System.out.println(i); | |
| } | |
| @Test | |
| public void testCalcul4() { | |
| int i = 1; | |
| // 5 : 1 + (2 (i+1)) + (2 (i du ++i)) | |
| i = 1 + ++i + i++; | |
| System.out.println(i); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment