0

Public Static Void Main

I still don’t exactly understand what they mean. Can someone explain in simple terms

5th Jan 2018, 10:50 PM
hann
2 Respostas
+ 3
I remember first learning Java way back when and this also confused me. In the first line of code you probably write are these various words each with different concepts. My best advice would be to say.. trust that they work, for now. You will progress more quickly by accepting that some things work, and a lot of times through practice these concepts become clear, like you're getting it for free! That said, here's a quick overview of what they mean: main: the entry point of a program. When you run an application, it looks for main for the place to start execution. public: an access modifier, this allows all parts of the code to view something. This is important for our program to find the main method! void: the return type of a method. In this case, main doesn't give us a result, so it doesn't need to return anything. static: probably slightly harder to appreciate, this makes something belong to a class instead of instances of a class. When we are in the application we can make objects. But how do we make an object before our program begins? We make main static so that it belongs to the class, and doesn't need an object to be created. Hope this helps, ask if you'd like something explained more :)
5th Jan 2018, 11:16 PM
Dan Walker
Dan Walker - avatar
22nd Jan 2020, 5:54 PM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar