+ 1

Print method result on console

How to print method result on the console? e.g. method: static int num(int x){ int result = x*x; return result; } how can I print result? System.out.print(//......)

1st Jan 2018, 6:24 PM
Sad
Sad - avatar
3 Respostas
+ 1
you are going to call the function in printing function. for example: int func(){ return 10; } System.out.printIn(func()); (edit)------ in your example you are gonna call it with parameters System.out.printIn(num(5)); //output: 25
1st Jan 2018, 6:39 PM
Mustafa K.
Mustafa K. - avatar
+ 1
Thanks! It helped☺
1st Jan 2018, 6:49 PM
Sad
Sad - avatar
0
document.write(x)
1st Jan 2018, 6:42 PM
Someone Else
Someone Else - avatar