title: Comparing 3 arrays and faulting Null to certain value
body: <pre><code>public class Temperature {
      private String degree;
      private String unit;
      private double number;
  }   
  public static Temperature[] getLargestArrayValue(Temperature[] t1, Temperature[] t2,
              Temperature[] t3) {
  
  
          int size = Math.max(t1.length, Math.max(t2.length, t3.length));
          Temperature[] noT1= new Temperature[size];
          Temperature[] noT2= new Temperature[size];
          Temperature[] noT3= new Temperature[size];
          
          Temperature[] largest = new Temperature[size];
          for (int i=0;i&lt;t1.length;i++) {
              noT1[i]=t1[i];
          }
          
          for (int i=0;i&lt;t2.length;i++) {
              noT2[i]=t2[i];
          }
          for (int i=0;i&lt;t3.length;i++) {
              noT3[i]=t3[i];
          }
          
          
          for (int i=0;i&lt;size;i++) {
            if (noT1[i].greaterThan(noT2[i]) &amp;&amp; noT1[i].greaterThan(noT3[i])) {
                largest[i]= noT1[i];
            } else if (noT2[i].greaterThan(noT1[i]) &amp;&amp; noT2[i].greaterThan(noT3[i])) {
                largest[i]= noT2[i];
            }  else if (noT3[i].greaterThan(noT2[i]) &amp;&amp; noT3[i].greaterThan(noT1[i])) {
                largest[i]= noT3[i];
            }
  
              }
            return largest;
      }// end of method getLargestArray 
  </code></pre>
  <p>I need to compare them and take the biggest value at each index from the 3. I tried equalizing their lengths(which randomly ranges from 1-5)  to the same size. Now the problem is that at one point some of them will have null in some indexes. I would like to default them to be 0C for degree, 0 for number and C for unit</p>
  <p>I I thought this would be it:</p>
  <pre><code>for (int i=0;0&lt;size; i++) {
              noT1[i].nullCheck();
              noT2[i].nullCheck();
              noT3[i].nullCheck();
          }
  </code></pre>
  <p>but I am not quite sure how to write this method since I have three variables for Temperature. I tried:</p>
  <pre><code>public Temperature nullCheck() {
      if (degree==&quot;&quot;|| degree==null || this==null || number==0.0 || unit==null) {
          degree=&quot;0C&quot;;
          number=0;
          unit=&quot;C&quot;;
      }
      
      return this;
  }
  </code></pre>