# Main Method

## What is a Method? (Interview Question)

A method defines an action that an object can perform. Think of it like a verb, just like objects can jump, sleep, etc.

Within a method's curly brackets is where you write the code for the action. This could be setting or retrieving variable values, performing calculations, printing outputs, etc.

When calling a method on an object, you use the dot notation (objectName.methodName). This tells the object to carry out what's defined in that method

## 🤖 The main() Method - Bringing Java Programs to Life!

The **main()** method is the heart and soul of a Java program ❤️. It is the entry point that kickstarts a Java application's execution.

<div data-full-width="true"><figure><img src="https://images.unsplash.com/photo-1538051046377-5ad74dc62f95?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwyfHxzdXBlcm1hbnxlbnwwfHx8fDE2ODk5MzAyMDB8MA&#x26;ixlib=rb-4.0.3&#x26;q=85" alt=""><figcaption></figcaption></figure></div>

**📍 Where to Find main()**

The main() method resides inside a class and must be declared as:

```java
public static void main(String[] args) {

} 
```

**🗝️ Understanding the Syntax**

* **public** - main() is accessible from outside the class
* **static** - main() can be called without creating an instance of the class
* **void** - main() does not return anything
* **String\[] args** - main() accepts a string array as parameter for command line arguments

**▶️ Starting the Execution**

The Java runtime calls the main() method to run your application. Code inside main() gets executed line by line.

**📤 Passing Inputs to main()**

The args parameter of main() can be used to pass inputs and configure the application at runtime.

**🎉 Using main()**

Typically, main() will:

* Create objects
* Call other methods
