title: Q: Register(class) java
body: <p>Have to code a register class in java eclipse following these requirements have done most of the requirements i have this one left:</p>
  <p>a) In your Register class add a sort method sortRegister(), that sorts the internal collection
  into its natural order, i.e. that prescribed by the compareTo method of its elements.</p>
  <p>this is what i have so far:</p>
  <pre><code>package lib;
  
  import java.util.ArrayList;
  
  
  public class Register {
  
          //Fields
          private ArrayList&lt;Name&gt; list;
          
          
          //Constructors
          public Register() {
              list = new ArrayList&lt;&gt;();
              
          }
          
          
          //Methods
          
          
          public void addName(Name n) {
              list.add(n);
          }
          
          public Name removeName(int pos) {
              return list.remove(pos);
          }
          
          public Name getName(int pos) {
              return list.get(pos);
          }
          
          public int registerSize() {
              return list.size();
          }
          
          public void clearRegister() {
              list.clear();
          }
          
          public boolean isRegisterEmpty() {
              return list.isEmpty();
          }
          
          
          public String toString() {
              return &quot;Register:[ list=&quot; + list + &quot;]&quot;;
          }
  
  
  }
   
  
  </code></pre>
  <p>how should i code the method?</p>