Java Applet runs without a main method?

和自甴很熟 提交于 2019-11-28 12:26:43

Java Applets have an init method instead of main. It's:

public void init() {... }
Donal Fellows

Yes, but applets aren't applications. There is a main method in the applet runner (assuming it's implemented in Java; it need not be) but the applet doesn't work that way; it gets loaded/instantiated from a file and then it proceeds along its lifecycle through initialization, starting, operating, stopping, and finally being destroyed. The code that sends it through these states is hidden from the applet's view; it just knows its in an environment that can run applets.

Applets differ from stand-alone Java applications in that they do not need to implement a main method.

Life Cycle of an Applet

Smamatti

Copied from google results:

Applets are standalone programs which require a third party tool for its execution that is either it is java enabled web browser or applet runner. So it doesn't have main(). It is possible to run a program without main.

Possible duplicate of:
Why do applets not need a main()?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!