What does 'public static void' mean in Java?

后端 未结 9 1056
忘掉有多难
忘掉有多难 2020-11-29 14:29

What does public static void mean in Java?

I\'m in the process of learning. In all the examples in the book I\'m working from public static void

9条回答
  •  攒了一身酷
    2020-11-29 15:19

    It means that:

    • public - it can be called from anywhere
    • static - it doesn't have any object state, so you can call it without instantiating an object
    • void - it doesn't return anything

    You'd think that the lack of a return means it isn't doing much, but it might be saving things in the database, for example.

提交回复
热议问题