public class Solution {
public static void main(String[] args) {
//write your code here
}
public static void sum(int a, int b) {
int c = a + b;
System.out.print(c);
}
}
My coding is correct but if no value is assigned to the variables a & b how do you know it's 2 + 2?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
MCantu
20 September 2020, 20:29
Sum is a method that takes in two arguments int a and int b.
When you called the Sum method inside main you are passing the values of 2 and 2 as arguments for the method sum...
I hope this helps.
0
Misiu
20 September 2020, 15:12
We don't know what values are a and b until we write in main():
sum(2, 2); --> a = 2, b = 2
or
sum(5, -3); --> a = 5, b = -3
0