Why some java methods in core libraries end with numbers?

Go To StackoverFlow.com

23

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

  1. java.util.Properties
    • load0
    • store0
  2. java.lang.Thread
    • start0
    • stop0
    • setPriority0

Usually they are private native methods (like in Thread class), but sometimes they are just private (Properties class)

I'm just curious if anybody know if there is any history behind that.

2012-04-04 06:57
by Petro Semeniuk
Where is Joshua Bloch? Maybe it used to be Sun's coding standard - Alvin 2012-04-04 07:19


4

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

2012-04-04 07:48
by Stephen C


12

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.

2012-04-04 07:12
by Mayank
The source (jre6) shows that the store and load functions call the load0 and store0 after wrapping the parameters - Thirler 2012-04-04 07:52


7

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.

2012-04-04 07:56
by vikiiii
Ads