+ 3

Explain me this code?

public class practice { public static void main (String[] args) { int x = 10; test(x); } static void test(int x) { System.out.println(x); } } I dont understand this code plz explain...

7th Sep 2018, 7:01 AM
Nitin Gutte
Nitin Gutte - avatar
5 Respuestas
+ 5
It's easy : 1. Program execution starts from main method. 2. At test(x), the value of x goes as argument in test(x) method 3.Program jumps to test method definition 4.In method definition it prints the value of x which is 10 though System.out.println (x)
7th Sep 2018, 7:36 AM
Rishabh
Rishabh - avatar
+ 14
Complete the Java course. Everything you wrote is covered by the course.
7th Sep 2018, 7:22 AM
Igor Makarsky
Igor Makarsky - avatar
+ 1
no se nada de java pero con lo poco que se, te puedo decir que lo que hace es declarar una variable (x) al que le asigna el valor 10, luego llama a una función definida que lo que hace es pasar la variable x como argumento de la funcion y luego lo imprime, lo que da de salida 10.
8th Sep 2018, 9:07 PM
Facu
Facu - avatar
+ 1
Facu I don't understand your language. Explain in English.
9th Sep 2018, 6:27 AM
Nitin Gutte
Nitin Gutte - avatar
+ 1
I do not know anything about java but with what little I know, I can tell you that what you do is declare a variable (x) to which you assign the value 10, then call a defined function what it does is pass the variable x as argument of the function and then print it, what gives output 10. 🤦‍♂️
9th Sep 2018, 3:39 PM
Facu
Facu - avatar