Why some java methods in core libraries end with numbers?

前端 未结 3 975
南方客
南方客 2020-12-08 05:17

It\'s common in a lot of classes in JDK, just a few examples:

  1. java.util.Properties
    • load0
    • store0
  2. java.lang.Thread
      <
相关标签:
3条回答
  • 2020-12-08 05:25

    The 0 after the method name is done so to distinguish between public and private methods having same name .

    Start function will call the start0 function. Those functions which ends with 0 is private method. And those which are not ending with number is public. You can check in any of the library.

    0 讨论(0)
  • 2020-12-08 05:36

    I think the history of this convention predates Java. I vaguely recall seeing it in C libraries in 4.x BSD Unix.

    0 讨论(0)
  • 2020-12-08 05:38

    I believe they are named like that because equivalent functions with same names exist in the code and just to distinguish between native helper functions and public functions they decided to suffix them with 0.

    in java.util.Properties both load, store and load0, store0 exist.

    0 讨论(0)
提交回复
热议问题