0

Plz help me to fix the error?

import java.util.Scanner; public class my { static void say(String x) { System.out.println(x); } public class Program { Scanner a = new Scanner(System.in); String b = a.nextLine(); say(b); public static void main(String[] args) { } }

9th Jul 2021, 2:36 PM
Shahir
Shahir - avatar
2 Answers
+ 2
First, closing bracket is missing in first class Second, the code you wrote in class Program should be inside main. Third, you can't call method of another class like that. Either create an object or call it using Class name since it is static. So, It should go like My.say(b);
9th Jul 2021, 2:48 PM
Alaska
Alaska - avatar
0
My.say(b); if you rename class my to My , it is recommended
11th Jul 2021, 6:12 AM
zemiak