+ 2
In which reason I should add static keyword to a method?
2 Antworten
+ 3
Generally if you are declaring a method inside the class which has your main() then it is recommended to use static keyword for the method which is going to be accessed within the main().
Because main() itself is static and you cannot access a non-static member inside a static method until and unless you create an Object of that class.
+ 5
Main reason of using static keyword is accessing methods or variable without insatnce of class.