Class SortedLinkedList

java.lang.Object
SortedLinkedList

public class SortedLinkedList extends Object
Represents a sorted linked list of integers. The list is created from a comma-separated string of integers.
 How to Run:

 javac -d bin *.java
 java -cp bin SortedLinkedList.java
 
 Command Used to create Javadocs:

 javadoc -d docs *.java
 
  • Constructor Details

    • SortedLinkedList

      public SortedLinkedList(String integerString)
      Constructs a SortedLinkedList from a comma-separated string of integers. If the string is null or empty, an empty list is created. If the string cannot be parsed, an error is printed.
      Parameters:
      integerString - A string containing comma-separated integers.
  • Method Details

    • getSortedLinkedList

      public LinkedList<Integer> getSortedLinkedList()
      Getter for the sorted link list.
      Returns:
      A sorted LinkedList of integers or null if the integer string was unable to be parsed.
    • toString

      public String toString()
      Returns a string representation of the sorted linked list.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the list, e.g., "[1, 2, 3]".
    • main

      public static void main(String[] args)
      The main method to demonstrate the SortedLinkedList functionality. Prompts the user to enter a comma-separated string of integers, creates a SortedLinkedList, and prints it.
      Parameters:
      args - Command line arguments (not used).