Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
[WHAT IS WRONG WITH MY CODE] Checks whether the inputted age is a āMinorā or an āAdultā
import java.util.Scanner; public class main { public static void main(String[] args) { ageCheck(); } public static void ageCheck() { Scanner input = new Scanner(System.in); int age = input.nextInt(); System.out.println(age); if (age > 12) { System.out.println("Adult"); } else { System.out.println("Minor"); } } } (It says āMain.java:3: error: class main is public, should be declared in a file named main.javaā) I tried applying what Iāve learned so far...and I still donāt get it.
5 Respostas
+ 3
call your class Main instead of main. āŗļø
+ 2
You have the class name same as the main function's name. So a naming collision occurred.
PS: Don't call yourself dumb. All the best =)
+ 1
Hi Rishi Thank you very much! I really appreciate it. Youāre very kind. Have a nice day!
+ 1
ruiririririri tnx, you too
o((*^ā½^*))o
0
Stefanoo Thank you very much! I really appreciate it. Have a nice day!