Java教程

【Java学习】-Inheritance syntax

本文主要是介绍【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.

这篇关于【Java学习】-Inheritance syntax的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!