I want to have a look at how Java implements LinkedList. Where should I go to look at the source code?
I want to have a look at how Java implements LinkedList. Where should I go to look at the source code?
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.
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.
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.
I would say start at the OpenJDK repository, but I don't see anything there for the LinkedList objects.
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.