title: Error when calling insertionsort method and how to print an arraylist
body: <p>I have created a program which stores temperature(double) and day(string) in an arraylist, then uses the comparable interface and an insertion sort to sort the arraylist. Now all that i have left is calling the insertion sort method and print out the original order of the arraylist and the sorted order. However when I call the insertionsort method it gives me an error stating "invalid method declaration; return type required".  Why am i receiving this error? Also is my print statement correct to print out the original arraylist? How would i update it to print out the sorted arraylist? Or can i print that out from the insertionsort method?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import java.io.*;
  import java.util.Scanner;
  import java.util.Arrays;
  import java.util.ArrayList;
  
  
  public class DailyTemperature implements Comparable&lt;DailyTemperature&gt;
  {
       //variables
      private Double temperature;
      private String day;
  
      //getTemp &amp; setTemp methods
      public double getTemp()
      {
        return temperature;
      }
  
      public void setTemp(double newTemp)
      {
        temperature = newTemp;
      }
  
      //getDay &amp; setTEmp methods
      public String getDay()
      {
        return day;
      }
  
      public void setDay(String newDay)
      {
        day = newDay;
      }
  
  
      public DailyTemperature(String day, double temperature) 
      {
        this.day = day;
        this.temperature = temperature;
      }
  
      public int compareTo(DailyTemperature other) 
      {
          if (temperature &lt; other.temperature) return -1;
          if (temperature == other.temperature) return 0;
          return 1;
      }
  
      public String toString() 
      {
          return("Day of Week" + this.getDay() +
          "Temperature" + this.getTemp());
      }
  
  
  }
  
  
  
  import java.io.*;
  import java.util.Scanner;
  import java.util.ArrayList;
  
  public class DailyTemperatureList 
  {
      public static void main (String [] args) 
      {
  
      ArrayList&lt;DailyTemperature&gt; dailytemps = new ArrayList&lt;DailyTemperature&gt;();
  
      dailytemps.add(new DailyTemperature("Mon", 87.1));
      dailytemps.add(new DailyTemperature("Tue", 88.3));
      dailytemps.add(new DailyTemperature("Wed", 81.2));
      dailytemps.add(new DailyTemperature("Thu", 84.0));
      dailytemps.add(new DailyTemperature("Fri", 76.3));
     }
  
     public static &lt;DailyTemperature extends Comparable&lt;? super DailyTemperature&gt;&gt;
     void insertionSort(ArrayList&lt;DailyTemperature&gt; dailytemps)
     {
         DailyTemperature temp = null;
         int position = 0;
  
         //loop from 2nd element on
         for (int i = 1; i &lt; dailytemps.size(); i++)
         {
             temp = dailytemps.get(i);
             position = i;
  
             while ( 0 &lt; position &amp;&amp; temp.compareTo(dailytemps.get(position - 1 )) &lt; 0)
             {
                 dailytemps.set(position, dailytemps.get(position - 1));
                 position--;
             }
              dailytemps.set(position,temp);
          }
      }
  
      insertionSort(ArrayList&lt;DailyTemperature&gt; dailytemps);
      System.out.println( dailytemps.toString() );
  
  
  
  
  
  }
  </code></pre>