Main () in C, C ++, Java, C #

Is main () (or Main ()) in C, C ++, Java, or C #, a user-defined function, or an inline function?

+5
source share
9 answers

This is a user-defined function required to execute a program. When you run your program in a compiled language, a function mainis what executes. For example, in Java, if you have a signature function public static void main(String ... args)in a class, then this class can be executed since the JVM will execute the contents of this method main.

An example in Java:

public class Test {
  public static void main(String ... args) { 
    System.out.println("Hello World");
  }
}

...

javac Test.java

...

java Test

Results in "Hello World" are printed on the console.

+14
source

, . . ++, .NET Java () , , , Main ( ) .NET , # VB.NET Main).

, , , . , / , " ".

+5

C ( ):

5.1.2.1

  • ( C - ), , . , , , 4, .

main(), , .

+4

( )...

+3

"" , - - main() avialable.

C/++/Java , , . . C:

  • main()

  • .

, (# , + "" ), - )

+3

C/++ , .

Java, ,

# - , .

- , .

0

, . , C main().

- , , , .

0

. , , GUI, .

0
source

In Java, main (String [] args) is the entry point for applications by convention (to make C ++ programmers comfortable). For applets or servlets, the code is called differently. Please note that the jar can contain any or none of these entry points and that each class can contain the main line, so the specified jar can be called in various ways as an application, if necessary.

0
source

All Articles