- 1

What is wrong here plis help

public class MyClass { static int sum(int val1, int val2) { return val1 + val2; } } class MainClass{ public static void main(String[ ] args) { //int x = sum(2, 5); //System.out.println(x); sum(2, 3); } }

24th Oct 2018, 4:24 PM
stephen haokip
stephen haokip - avatar
1 ответ
+ 3
MainClass cant see function sum because it is in MyClass. solution: 1 replace sum function into class MainClass. solution 2: Use MyClass.sum() instead of sum()
24th Oct 2018, 4:49 PM
Sokrat_Poghosyan
Sokrat_Poghosyan - avatar