+ 1

How does static work in Java and C#?

When you make the main method static, what does that do? I know it stops an instance from happening but what would happen if an instance did happen? If it's just main(String [ ] args, then even if an instance was created, would it matter?

8th Oct 2019, 5:12 PM
Subject Loser
Subject Loser - avatar
2 Antworten
+ 2
This helps maybe. https://www.sololearn.com/learn/Java/2159/?ref=app Take a look at the comments for more informations. The main must be static because you can't call the method if is not. If a method is not static then the method belongs to the class in there the method is written and you have to create an instance from the class first to call the method.
8th Oct 2019, 5:40 PM
Stefanoo
Stefanoo - avatar