-2

Couldn't find them with a search and I want to see how they are implemented

Anon855
  • 17
  • 4

4 Answers4

1

Oracle's implementation is largely based on openjdk. You can browse and search the API and view the source code online at docjar.com for example. http://docjar.com/docs/api/

Joni
  • 108,737
  • 14
  • 143
  • 193
  • Or you can `ctrl + click` on the code in your IDE to find it. ;) – Peter Lawrey Jun 29 '13 at 10:38
  • 1
    If you use an IDE and have the source installed... Big fan of your blog by the way. – Joni Jun 29 '13 at 10:54
  • Cheers, I should have more time over the Summer to add to it. If you like my blog you might like the `Performance Java User's Group` https://plus.google.com/u/1/communities/107178245817384004088?cfem=1 – Peter Lawrey Jun 29 '13 at 10:58
1

Most of the APIs are in the JDK in a file called src.zip. If you use an IDE it will find this archive for you automatically and if you show you the source.

e.g. Say you have

String s = "Hello World";
String hi = s.substring(0, 5);

You want to see the code for substring so you <ctrl> + <click> of substring and it takes you to the code which might look like this.

public String substring(int beginIndex, int endIndex) {
    if (beginIndex < 0) {
        throw new StringIndexOutOfBoundsException(beginIndex);
    }
    if (endIndex > value.length) {
        throw new StringIndexOutOfBoundsException(endIndex);
    }
    int subLen = endIndex - beginIndex;
    if (subLen < 0) {
        throw new StringIndexOutOfBoundsException(subLen);
    }
    return ((beginIndex == 0) && (endIndex == value.length)) ? this
            : new String(value, beginIndex, subLen);
}

With Java, your life will be much easier if you learn to use your IDE.

There is some code which is not in the src.zip. This is very low level code and you should think carefully before going too low level into the JVM.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

Here it is. At least you could have searched properly.

Jayram
  • 18,820
  • 6
  • 51
  • 68
0

You might want to see http://openjdk.java.net/. However, I am not 100% sure that it is what you are looking for.

Vincent Cantin
  • 16,192
  • 2
  • 35
  • 57