r/javahelp • • Jan 29 '26

What is a public static void?

Why do some not include public in it, like:

static void

why not add public?

what does public even mean?

0 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/Miserable_Bar_5800 Jan 30 '26

tnahnks for the help but i was just confused about it because i already tried it with public and without and it showed the same output

1

u/vowelqueue Jan 30 '26

Are you talking about the “main” method of your program?

If so, this behavior is something that changed very recently. For nearly 30 years in Java the “main” method of a program needed to be public and static, and accept a String array as a parameter:

public static void main(String[] args) {}

In the latest release it’s now more flexible, you can you also write just:

void main() {}