Search code examples
javaapisource-code-protection

Is it possible to view source code of an API class?


E.g I'd like to see how Integer Class is coded. Is that available?


Solution

  • When you install JDK, there is an option to install the sources, which is selected by default.

    jdk installation

    After installing, when you open a project, IDEs will usually automatically index Java sources. If not, you can attach the sources to your project depending on your IDE.

    Alternatively, you open <JDK_HOME>\src.zip and see the Java sources.