
Java
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).
Copyright © 2026 eLLeNow.com All Rights Reserved.