Singular Linked List

What is a singular linked list?

These linked lists are made up of a chain of nodes that are connected to each other in a linear fashion. The first node is called the head and has a pointer to the next node in the list. This node has a pointer to the next node as well as a data field to store an object. This chaining continues until the last node in the list, often called the tail, who's next pointer points to null.

Implementation of a singular linked list

public class LinkedList﹤E extends Comparable﹤? super E﹥﹥{

	private ListNode ﹤E﹥ head; 
	private int size;

	public UnorderedList(){
		head ﹦ new ListNode﹤E﹥();
		size ﹦ 0; 

  public void add(E obj){
    if(isEmpty()){ ﹦ new ListNode﹤E﹥(obj, null);
    ListNode﹤E﹥ prev ﹦; ﹦ new ListNode﹤E﹥(obj, prev);

  public E remove(E obj){
    ListNode﹤E﹥ i ﹦; 
    ListNode﹤E﹥ prev ﹦ head;

      if({ ﹦; ﹦ null;
      prev ﹦ i;
      i ﹦;
    return null;

  private static class ListNode﹤E﹥ {
    private E info; 
      private ListNode﹤E﹥ next;

      public ListNode(){
        next ﹦ null;
        info ﹦ null;

      public ListNode(E obj, ListNode ﹤E﹥ nextNode){
        info ﹦ obj;
        next ﹦ nextNode;

This code can also have other functions to manipulate data.

Full course
Next Lesson