2

I want to know the difference between init and main method of java

Guillaume
  • 5,535
  • 1
  • 24
  • 30
Quamar Niyaz
  • 21
  • 1
  • 2

3 Answers3

6

The main method is used as an entry point for applications, the init method is used as an entry point for applets and servlets.

1

static void main is usually the declaration for a method which allows an entry point for launching the Java file/application. however, main can also be used to name any random method.

while init is one of the many random names which can be selected for naming a method [satisfying the basic rules for naming methods]. typically, programmers, in Java or any other programming language, like to name a method init if there's some initialisation routine to be run.

anirvan
  • 4,797
  • 4
  • 32
  • 42
0

init method is used when servlets or applets is initialize while main method is used for entry point of program....

If there is first time request for servlet then first of all servlet's init method is called and also some properties may be initialize at that time While when you start your application main is entry point for that .......means main is first process for your application

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Ravi Parmar
  • 1,392
  • 5
  • 24
  • 46