Bonjour,
Donc on nous demande d'afficher le carré du 5; pas de soucis jusque la.
Cependant tout comme "Fiona" qui as posée la question en 2020 je ne saisis pas où, dans le corps de la lesson, je trouve l'explication.
Pouvez vous m'expliquer la logique à quoi sert le passage :
}
public static int carre(int a) {
return a * a;
}
si nous pouvons écrire System.out.println(carre(5)); directement ?
Merci d'avance
package fr.codegym.task.task01.task0127;
/*
Carré d'un nombre
*/
public class Solution {
public static void main(String[] args) {
int a = 5;
System.out.println(carre(5));
}
public static int carre(int a) {
return a * a;
}
}
P.S int a = 5; ne sert a rien j'ai oublié de le retirer.
Explication requise
Discussion en cours
Commentaires (2)
- Populaires
- Nouveau
- Anciennes
Tu dois être connecté(e) pour laisser un commentaire
Dima
27 août 2021, 10:49
Oh, i see now.
Thank you so much!
0
Gellert Varga
27 août 2021, 10:32
This is a course where you are sometimes asked to do things that are not explained in the lesson text.
This is intentional.
It is intended to prepare the future programmer for real life, where you will encounter countless times things that have not yet been explained to you.
This is to improve your skills:
- to search and find for answers
- endure and get used to the frustration of constantly facing the unknown.
Translated with www.DeepL.com/Translator (free version)
To see the logic of the program, see the attached picture.
![]()

+2