title: Circular Linked List of Size K
body: <p>I have a question on creating a single <code>Circular Linked List</code> without an add method. Just an inner class of Node, and then a constructor outside with a <code>toString</code> method. <br>
  I am having a hard time <code>returning</code> the <code>List</code>, I continually return nothing. and I am lost to as why because I cannot implement an add method. I have to create a circular Linked List within my constructor, so that gives me a little insight on it. But how would I assign the values to my <code>Nodes</code> of <code>head</code> and <code>tail</code></p>
  
  <pre><code>class Number{ 
  
  class Node
  {
          public int num=0;           // node's position in line
          public Node next=null;  // Reference to next node
          /**
          * Node constructor, initializes number
          */
  
          public Node(int number)
          {
                 //
              num = number;
              next = null;
          }
  
          public String toString() {
              return "" + num;
          }
  
  }
  
  private int number;
  private Node head = null;   // Linked list of prisoners
  private Node tail = null;   // Tracks end of list as it is constructed
  
  /**
   * constructs a circular linked list of
   * @param n Nodes, current is the first Node and tail is the last Node (next of tail is current)
   */
  
  public Number(int n)
  {
      //
      number = n;
      LinkedList numb1 = new LinkedList();
      for (int i = 1; i &lt;= number; i++) {
          numb1.add(i) //head I will have 1, 2, 3... n
      }
      head = null; //how would I make this reference head?
      tail = null; //how would I make this reference tail?
   }
  
  /*
   * prints all Numbers starting from head until tail
   */
  @Override
   public String toString()
   {
  //
       String strVal = "";
       for (Node current = head; current != null; current = head.next) {
           strVal = strVal + current.num;
       }
       return strVal;
   }
  </code></pre>
  
  <p>I think the reason for this is in the for <code>loop</code>. <br>
  By have the <code>current != null</code>, it keeps going because current can never be null as it references endlessly because it is a circular Linked List. However, it would at least return something instead of nothing.</p>
  
  <p>Say I call
  <code>Number newNum = new Number(6);</code> <br>
  <code>System.out.println(newNum);</code><br>
  I should out put<br>
  <code>1 2 3 4 5 6</code></p>