编程语言
首页 > 编程语言> > 【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.

标签:Even,Java,Inheritance,syntax,public,classes,each,main,class
来源: https://www.cnblogs.com/yidianling/p/15908136.html