Int main (); C - Java equivalent

I am a university student and new to java. Last year, in the second semester, we did some C programming. I test a lot of things before I really understand this. In C, I only need to start with int main () to start coding. Java is a bit confusing. Why, I “need” (I'm not sure I need to start this path) to start with

public static void main (String[] args)

if I will not use the argument in my program. It:

public static void main ()

gives me an error. I do not want to read any arguments.

I hope you understand - English is not my native language.

+3
source share
4 answers

It is simply a definition of language.

Signature:

public static void main (String[] args)

Java, . , args, .

.

+7

C . int main(), . , C, , ​​ int foo(void), int foo(). C int main(int argc, char *argv[]), C , , int main(). Java - ( ), C, , , main.

+4

Java . , , , .

IDE , .

, , groovy PHP, Python, Perl bash.

EDIT: Java , , . KDB

(!R)@&{&/x!/:2_!x}'!R

1 R .;)

+1

If you are not reading any arguments, the args array will be just empty. I don’t think there are any technical reasons why you cannot leave an argument in Java as you can in C, but the standard just dictates that it should be there.

+1
source

Source: https://habr.com/ru/post/1791544/


All Articles