2nd Feb 2018, 5:19 PM
Rostislav
Rostislav - avatar
8 ответов
+ 1
Because you capitalized the words. java is case sensitive, if you don't write exactly how they are, throws an error
2nd Feb 2018, 5:28 PM
voidneo
+ 6
This is the way you have to do it. public class Cat { static void Voice(){ System.out.println("Meow!"); } } class A{ public static void main(String[] args) { Cat.Voice(); } } The reason is that you created the Voice method as static, and that makes that you can call the method without creating an object of that class, however, the Voice method is in other class, so we reference it: Cat.Voice(). btw: should be 'voice' in lowercase.
2nd Feb 2018, 5:58 PM
Fabio
+ 3
Please, Make your code public, and tell us if any comment did help you...
2nd Feb 2018, 6:11 PM
Fabio
+ 2
keyword class is with lowercase c
2nd Feb 2018, 5:22 PM
michal
+ 2
It didn't help me:(
2nd Feb 2018, 5:25 PM
Rostislav
Rostislav - avatar
+ 2
Thank you all!
2nd Feb 2018, 5:51 PM
Rostislav
Rostislav - avatar
+ 1
you declared wrong the class in line 7. try this: public class A {
2nd Feb 2018, 5:24 PM
voidneo
0
Yes, it helped me, thank you)
2nd Feb 2018, 7:36 PM
Rostislav
Rostislav - avatar