Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interesting call to main method

Tags:

java

I was around Wikipedia reading about a programming language called 'D', it is the first time I read about it.

It was curious to me that the syntax looks very similar to Java. But most interesting was when I saw their main method uses char[][].

I opened up Eclipse and I tried this:

public static void main(char [][] args){
}

I was surprised when I saw it compiled with no syntax errors, but I did not understand why.
Can someone explain to me why this call to the main method can compile in Java?

like image 359
javing Avatar asked Dec 21 '22 12:12

javing


1 Answers

As what you have written is valid Java syntax (static void method with name main and as argument a two dimensional char array) it will compile. The problem however is, that this main method will not work as entry point to a Java program, as this has to have the signature:public static void main(String[] args).

like image 132
dcn Avatar answered Jan 06 '23 00:01

dcn