Super class constructor called last in Swift, but called first in Java? [closed]

This answer invites for opinions, but the real answer is: you are asking the wrong question.

In programming, you use the tools you know to help you do the job you have to do.

Each and any tool has its own properties, pros and cons. As a professional; you simply know about these things; and you make sure you apply your knowledge accordingly.

Thus: it is a waste of time to ask “what is better”. You might ask: what are the specific advantages; or problems with a certain approach. And coming from the Java side, the nice thing about running the constructor first is (for example): you can be assured that all these constructor calls took place before anything else happens.

In other words: the only thing that you can do there: study those two links (and probably additional tutorials, language specs, … ) in detail to understand how those two different languages go about initializing new objects. Understand the differences; and then decide for yourself what matters to you in your context.

Leave a Comment