+ 1

If x=5 in one method and another method (x*x); is called inside it then sop(x)=5 in first method??

How Variable valve change

29th Dec 2019, 3:54 AM
Saumya Mishra
Saumya Mishra - avatar
3 ответов
+ 2
Share your code so we can check the error.
29th Dec 2019, 3:56 AM
Chetali Shah
Chetali Shah - avatar
+ 2
You didn't return x. So the value of x is not changed. Do the following changes: public static void main (String [] args) { int x=5,y; y=square (x); System.out.print(y); } int square ( int x) { int y=x*x; return y; }
29th Dec 2019, 4:06 AM
Chetali Shah
Chetali Shah - avatar
0
public static void main (String [] args) { int x=5; Square (x); System.out.print(x); } Static void square ( int x) { Int x=x*x; }
29th Dec 2019, 4:01 AM
Saumya Mishra
Saumya Mishra - avatar