Hey guys, i have a question although i made right the exercise; so, the question is: why i need to write Dog, Cat and Mouse classes STATIC here?
Thank's a lot,
i love you all!
Why STATIC here?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Cristian Belu
23 August 2019, 10:33
Actually you don't need to write static classes in this case but, some short explanation is:
Java Static Classes
For java classes, only an inner class can be declared using the static modifier.
For java a static inner class it does not mean that, all their members are static. These are called nested static classes in java.
The static modifier is associated only with methods and variables, not classes. The static modifier is used to specify a method that can only be declared once. No sub classes are allowed to implement a method of the same name. This is used for methods, such as main, that are entry points into a program. The operating system would not know which method to call first if there were two main methods. Static methods are used to specify methods that should not be overridden in sub classes.
Here are 2 more articles that explain the static modifier:
https://www.geeksforgeeks.org/static-keyword-java/
https://www.geeksforgeeks.org/static-class-in-java/
+2
Cristian Belu
23 August 2019, 10:46
This is the solution that i have used, there is no static class or method in my solution except the main.
0