I want to have a look at how Java implements LinkedList. Where should I go to look at the source code?
-
It is the source code of the jdk, not the jvm. – peterh Jan 23 '15 at 20:30
10 Answers
Install the Java SE Development Kit from http://java.sun.com/javase/downloads/index.jsp.
Once installed, you should find an archive called src.zip
in the top of the JDK installation directory. The Java source code is in there.
The file is java/util/LinkedList.java
.
update: You may also like to visit the online OpenJDK Source repository. See this answer below.

- 1,472
- 1
- 16
- 23

- 538,548
- 86
- 673
- 828
-
Bill, this doesn't appear to be the case with the latest Java update (7u51). I wonder what the deal is... – ryvantage Jan 16 '14 at 00:48
-
1They seem to have moved the JDK source to http://hg.openjdk.java.net/jdk7/jdk7/jdk/ – Bill Karwin Jan 16 '14 at 01:54
-
You have the source in the docjar:
LinkedList.java (from the openjdk-7)

- 1,262,500
- 529
- 4,410
- 5,250
-
-
-
@Qw3ry That is possible indeed. This was one of my first answers on this site eleven years ago. – VonC Aug 05 '19 at 09:40
The sources are hosted at hg.openjdk.java.net. You can find the library sources for a specific JDK version under src/share/classes
. For example, the JDK 8 source for java.util.LinkedList is located at:
hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/share/classes/java/util/LinkedList.java
You can follow the instructions here to explore the source.

- 1,472
- 1
- 16
- 23

- 281
- 2
- 5
grepcode.com has source code of almost all opensource projects. It also provides common IDE features like find usages, derived types, etc.
Here you can find LinkedList source: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/util/LinkedList.java/

- 1,911
- 1
- 22
- 19
As previously said, you have a src.zip file installed with Sun JDK if you have selected it during installation. Moreover, if you use eclipse and add a JDK to your JRE list, it will attach automatically the sources to the jar and if you try to open a class with Ctrl+Shift+T (Open Type), you type LinkedList, and it will show you the code of the class.
If you have a JDK, you can find the source in the src.zip file.
If you have an IDE, you can just ctrl+click or similar on the class/method you want to see the definition of.

- 35,493
- 19
- 190
- 259

- 525,659
- 79
- 751
- 1,130
-
Intellij Idea has not found the src file automatically. Thanks for file reference. – Flowy May 23 '16 at 07:05
zGrepCode has an online directory of Java open source code. Here is the Sun Java classes available: https://zgrepcode.com/java/openjdk/10.0.2/java.base/sun/
And here is the LinkedList implementation code. Hope it helps.

- 1,630
- 9
- 27
- 46
I would say start at the OpenJDK repository, but I don't see anything there for the LinkedList objects.

- 2,340
- 19
- 31
The best way to view java source code is to install Intelli-J community edition. Create a new Java project and inside your project create a new class. Inside class if you want to see the source code of LinkedList, create a new LinkedList object as follows:
public class LinkedListWatch{
public static void main(String[] args){
LinkedList linkedList = new LinkedList();
}
}
Now ctrl + mouse left click
on LinkedList
class, will take you to LinkedList source code.
You can explore many things and it could be very useful.
You can look at the implementation of Stack class also; very helpful.
Enjoy searching java open source code.

- 1,129
- 12
- 10
-
This isn't useful if there is no attached source documents. Why would you even post this after reading the other answers that explain where to get the source documents? – superPhreshHackerKid Jul 25 '18 at 00:33
-
I am sure you missed something, I found it very convenient to look for Java source code inside Intellij, check my updated post for screenshots – HA S Jul 25 '18 at 01:18
-
This is fine for IntelliJ, but what about when you're using an IBM implementation of Java and they didn't include the Java source documents? Someone should download IntelliJ to view them? I disagree, they should do as Bill answered in '08; navigate to the src.zip to view / attach the source code. – superPhreshHackerKid Jul 25 '18 at 19:23
-
@superPhreshHackerKid You can do this in Eclipse and pretty much any IDE. Plus, you get to browse through the source code as you would with your project. That's far better than dealing with the src.zip yourself. – BaSsGaz Dec 24 '20 at 19:39