Why is the main method static in Java? - Java Explanations

preview_player
Показать описание
Why is the main method static in Java? - Java Explanations

Ever wondered why the main method is static in Java? Here we go through not only the static keyword, but also all the other keywords that make up the main method: public, void, String[], and args.

We also teach Python. If you would like to learn about Python, check out our course on Udemy:

-- Links --

Рекомендации по теме
Комментарии
Автор

Short answer: The main method can be called from JVM WITHOUT instantiating the class where Main is located

Pete_Delfina
Автор

This is fantastic because it combines explaination of static in main class as well as static in general, thanks

tomekmynarski
Автор

Thank you for this video. It's very helpful and well explained.

technscholbus
Автор

Thank you so much! My book didn't really describe this well. Keep going your videos are really clear

lukedonnelly
Автор

I sought of get your explanation. However, I thought when a program starts it is basically the system initializing an instance of the class?

tanxunyiqie
Автор

Thank you. Finally a video that I can understand. All the others are made by an indian narrator. -.-

moover
Автор

so what would actually happen if you didn't specify main method as static?

trzmaier
Автор

I spent days making and correcting logic for my program only to code it and to know that main method cannot be non static so I cant use members of main class in main method like in some other languages !!! sed life !!!

anb
Автор

As per my understanding, static methods have to be called by Class itself. But why we are able to call it by objects also. It seems misleading. We should get error.

mannu
Автор

i wish i was just a robot that can just do as i am told, why do i have to question every little thing, it makes my life impossible, i really do not need to know every little detail of the main method, but why must i google it? why can't i be that person at work that just uses the code? why?

oscarmonroy
Автор

That last part was actually pretty crucial but u decided to not explain it. That kinda sucks =/.

moyashimugiwara
Автор

Thanks heaps. All these basic tutorials keep explaining this badly.

thexxmaster
Автор

Very confusing, sorry. Perhaps I am not at a point yet to understand what you are talking about.

davidbrown