【Java学习】-Inheritance syntax

You can create a main() for each one of your classes; this technique of putting a main() in each class allows easy testing for each class.

Even if you have a lot of classes in a program, only the main() for the class invoked on the command line will be called. Even if a class has package access, a public main() is accessible.

So to allow for inheritance, as a general rule, make all fields private and all methods public.

posted @ 2022-02-18 12:22  易点灵通  阅读(30)  评论(0)    收藏  举报