Essayez de deviner la valeur du retour de la méthode g avant de vérifier en exécutant le code
Last active
September 12, 2023 13:24
-
-
Save nherbaut/22298637dbd97048ee2c5cde9b1f3e1a to your computer and use it in GitHub Desktop.
L2.1.7 Les conditions.1
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
| public class TypesL2 { | |
| static int f(int x, int y) { | |
| if (x < y) { | |
| System.out.println("x<y"); | |
| return y + x; | |
| } else { | |
| System.out.println("x >= y"); | |
| if (x < 8) { | |
| return y + 7; | |
| } | |
| } | |
| return x - 2; | |
| } | |
| static int g() { | |
| int a = f(3, 4); | |
| int b = f(a, 5); | |
| return b; | |
| } | |
| public static void main(String... args) { | |
| int returnValue = g(); | |
| System.out.println(returnValue); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment