Java return returns blank
•
Java
I'm trying to create a Java method that returns the sum of two values X and y Currently, when I run the code, the output returns nothing Is there any way to get the value that returns the sum without modifying "getsum (x, y);" On line 6, use the return method???
public class ZawMethods2 { public static void main(String[] args) { int x = 7,y = 45; getSum(x,y); } public static int getSum(int x,int y){ int sum = x+y; return (sum); } }
Thank you!!! I'm still at the beginning of coding, so I appreciate all the help
Solution
Sorry, I don't think you can modify the getsum method Just add system out. println(sum); To getsum method
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码