0
why this error?
import java.util.Scanner; class Shubham{ public static void main(System[]args){ Scanner sc=new Scanner(System.in); Shubham Jhunki=new Shubham(); jhunki.eating(); jhunki.dancing(); jhunki.walking(); void eating(){ System.out.println("Jhunki is eating"); } void dancing(){ System.out.println("jhunki is dancing"); } void walking(){ System.out.println("jhunki is walking");} } }
4 ответов
+ 3
Look at public static void main. You put (as argument) System[] args. System is not a datatype. Change it to String[] args and it will work.
+ 3
We have to write the other methods outside of main method in a class
And another is you have created a object of your class as Jhunki but while you are calling the method you used jhunki here the J should be capital
The object name while calling should be same as while creating
+ 2
Specify error & what code should do. Surely someone will help
+ 2
Another one in main method delclaration also wrong you should use String[] args
I think there are two more main method declaration you may google as what are the main method delcarations in java