I do not understand how I can use sum function to add 2+2. Could anyone explain that step by step?
For instance
package com.codegym.task.task01.task0128;
/*
As simple as 2+2
public class Solution {
public static void main(String[] args) {
int a = 2;
int b = 2;
int c = sum(a,b);//write your code here
}
public static void sum(int a, int b) {
int c = a + b;
System.out.print(c);
Why this won't work? What is the role of the last 3 lines that are given in this task?
*/
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);
}
}
Many many thanks for insight!