Hello, I encountered a problem of the following kind: there is a public
class. When trying to create a descendant with a modifier other than public
writes
"modifier ... not allowed here".
I read on the Internet and found that the class heir can have the same access level or “wider” than the parent. When creating a third class that is not someone's heir, writes
"modifier ... not allowed here"
with private
. With the public
modifier it is clear (there can be only one private
in one java file), I don’t need a protected one - there will be no heirs. All classes are in the same file and one file (the program is educational and small). There is no problem only with the package modifier.
Explain, please, what is wrong.
package Animals; public class Bird { public static void main(String[] args) { } } class Parrot extends Bird { } private class Cat { }