0

Public, static and void

Depending on the program I want to run do I need to write "public" "static" or "void" as the main?

28th Feb 2020, 7:44 AM
Walt Rothschild
Walt Rothschild - avatar
2 Respuestas
+ 1
It's depends on program concept requirements.. Public is a keyword that is used as an access modifier for methods and variables. A variable (field) or a method declared as public is visible to and may be accessed by all classes defined in different packages. In local variables, static is used to store the variable in the statically allocated memory instead of the automatically allocated memory. In computer programming, when void is used as a function return type, it indicates that the function does not return a value. When void appears in a pointer declaration, it specifies that the pointer is universal. When used in a function's parameter list, void indicates that the function takes no parameters.
28th Feb 2020, 7:48 AM
Scooby
Scooby - avatar
+ 1
Yes your main() should have all the 3. 'public' 'static' 'void'.
28th Feb 2020, 8:05 AM
Avinesh
Avinesh - avatar