gpt4 book ai didi

java - 'String args[]' 和静态在 'public static void main(String[] args)' 的解释

转载 作者:IT老高 更新时间:2023-10-28 20:36:58 25 4
gpt4 key购买 nike

你怎么能很好的解释一下,给一个初学者,下面String args[]的含义和static的使用摘录?

class FirstApp {
public static void main(String[] args) {
...
}
}

最佳答案

我会分手

public static void main(String args[])

部分:

public

It means that you can call this method from outside of the class you are currently in. This is necessary because this method is being called by the Java runtime system which is not located in your current class.


static

When the JVM makes call to the main method there is no object existing for the class being called therefore it has to have static method to allow invocation from class.


void

Java is platform independent language and if it will return some value then the value may mean different things to different platforms. Also there are other ways to exit the program on a multithreaded system. Detailed explaination.


main

It's just the name of method. This name is fixed and as it's called by the JVM as entry point for an application.


String args[]

These are the arguments of type String that your Java application accepts when you run it.

关于java - 'String args[]' 和静态在 'public static void main(String[] args)' 的解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11952804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com