Why is startApp () used instead of a constructor in Java ME applications?

Many Java ME tutorials use the startApp () method to create and initialize objects, and the constructor remains empty. However, the startApp () method is also called when the MIDlet returns from its paused state. This causes all objects to be reinitialized and any changes made are lost.

I also noticed that the netbeans IDE in its automatically generated code uses a lot of if (object == null) statements in startApp () to check if the object was previously created.

Doesn't it make sense to just do all the creation and initialization of the object in the constructor itself? Is there any reason not to do this?

+3
source share
1

MIDP.

, MIDlet, , Java .

, MIDP , startApp, pauseApp lcdui.

, .

- , (, , ...), MIDlet .

, , , , , ( , ) .

, JVM-. JVM, ( J2ME), , MIDlet.

+3

Source: https://habr.com/ru/post/1735057/


All Articles