What is the difference between main function in C java?

Java

1 answer

Answer

1010511

2026-05-02 14:11

+ Follow

Java
Java

// C

int main(int argc, char** argv) {

return 0;

}

// Java

class MainClass {

public static void main(String[] args) {

}

}

Differences:

* Java main method must be in a class; C has no class, so no such requirement exists. * Both accept an array of command-line args. * ** Java arrays know how long they are; C does not and thus the main function must have an additional parameter to know the length of the array. * The Java main method has a specific format; the C main function seems to be allowed to differ. * ** The C main function seems to be able to accept different numbers of arguments and have different return types (assuming the implementation allows it).

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.