+ 1
Challenge for you: why this code doesn't run ( I don't know😉)
public class MyClass { public static void main(String[ ] args) { int x = 5; int y= square(x); System.out.println("The square of "+x+" is "+y); } static void square(int num) { num *= num; } }
7 Answers
+ 5
Because you aren't returning value from function like "return num" in square function
+ 5
+ 3
Great ! thanks Akshay, code monkey and Abhay!
+ 2
Ok i will try ...
+ 2
Here is your modified code..
https://code.sololearn.com/cGh0WTW1QB4J/?ref=app
+ 1
Theo Martier type @ then a list of suggestions will pop and select the name of person you want to tag
+ 1
You should use return statement in your 'square' function then it will work