How do you incorporate the main features of Java into your design?

You can actually skip this first part because it's confusing, but I'll keep it here because I want to know if others feel the same I am a CS undergraduate and have been using java for 3 years. I still find it difficult to understand how to include the main function in my design Putting it in a class is an error in itself, but inserting it into another class file is also an error I see the latter is like this because it doesn't fit the rest of the class and makes it non stick For example, I can't paste a main function on my documentreader object This has nothing to do with the object On the other hand, I can't just make a main class, because there can only be one main function in object-oriented programming, so you should effectively create a micro world in the aspect of objects For that tiny world, there seems to be nothing around a single object It will not be like the narrator and character in the story, because it has nothing at the same time I like the style of C, which has main functions independent of everything It separates the narrative of the story from the interactive roles

I want to know how professionals combine the main methods with other code How to make it consistent with the rest of the design Also, are they usually long or short?

Solution

I save the main () function in a class called my project When you start the application from the command line, type:

java com.domain.project.ApplicationName

It seems that I have a simple logic of launcher name instead of:

java com.domain.project.AClassWhichDoesntLookLikeAMainClass

Or (too) classic

java com.domain.project.Launcher

But don't worry too much about this class, which may never be executed by the end user Scripts or other executables start most of the time

Another thing, your main () method may become heavy, especially if you really use the main args to get more cli options Maybe it's worth your class

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>