且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

相对较新的Java编程但是“Android的工作室”混淆

更新时间:2023-02-19 23:24:14


  

我被教导说所有的Java程序都需要一个主的方法,这是在公共静态无效的主要(字串[] args){}


块引用>

这完全取决于你的节目的定义。


  

这是如何工作的?


块引用>

有任意数量的开发人员可以编写Java code方式,开发商可能认为是一个计划,即不涉及开发人员编写方法:


  • Java Servlet或者其他形式的Java Web应用程序不涉及该Web应用程序的作者有写


  • 我不记得Java小程序要求方法,但它是一个很长一段时间,因为我看着那些


  • 插件用于其他基于Java的程序,就像你所运行的非常的Andr​​oid Studio中,不涉及插件作者写了


  • 一个JUnit测试套件不涉及测试套件笔者写


有责任的的东西的加载你的code和运行它。这是什么东西是,和你的计划的预期,达到的东西的作者。仅仅因为通过 的Java运行Java程序 命令恰好需要方法做不是说的所有的运行Java程序需要​​方法。

在了Android的情况下,东西是Android框架类,与其他低级别的管道在Android应用的过程音乐会。

Recently I've been doing some android programming using Java and the Netbeans IDE (I have experience with Turbo Delphi, python and some c#), I have gotten to the stage of GUI's, for loops, switch statements, arrays and using some of the libraries (mainly from the course I am taking right now at my high school).

I have been taught that ALL java programs need a 'main' method and this is under public static void main( String[ ] args ) {}. However when using android studio (which uses the IntelliJ IDE), the base code looks different and has no 'main method'.

How does this work?

I have been taught that ALL java programs need a 'main' method and this is under public static void main( String[ ] args ) {}.

That depends entirely upon your definition of "program".

How does this work?

There are any number of ways that a developer can write Java code, that the developer might consider to be a "program", that does not involve the developer writing a main method:

  • A Java servlet or other forms of a Java Web app do not involve a main method that the author of the Web app has to write

  • I don't recall Java applets requiring a main method, but it's been a long while since I looked at those

  • Plugins for other Java-based programs, like the very Android Studio that you are running, do not involve the plugin author writing a main method

  • A JUnit test suite does not involve the test suite author writing a main method

It is the responsibility of something to load your code and run it. What that "something" is, and its expectations of your program, is up to the authors of the "something". Just because running a Java program via the java command happens to require a main method does not mean that everything running a Java program requires a main method.

In the case of Android, the "something" is the Android framework classes, in concert with other low-level plumbing in your Android app's process.