I'm a beginner in programming.
When you start studying Java, the first sentence you see is public static void main (String[]args), but you don't understand why you use the main method that does not return the return value and the return statement at the same time.
I would appreciate it if you could let me know.
java
public static void main(String[])
cannot return a value with return
.Writing such code results in a compilation error.
If there is such a code in any reference document, it may be a document error or misreading.
when return value is required
int main(...)
using
if no return value is required
void main(...)
That's all I have to say
In , you cannot use these two at the same time.
Is it okay to say #?
For your information, if you want to return the results to the operating system in main, you can use System.exit; to complete the process to determine whether the operating system is successful or abnormal.
© 2023 OneMinuteCode. All rights reserved.