title: Is there any way that I can multiply the first and the last elements in this list?
body: <p>I'm trying to multiply the first element of this list to the last element and then the second-first element to second-last element and so on. Is there a better way I con do it? tried to do so but I'm reading the same element in 3 times in my inner loop. </p>
  
  <pre><code>    long sum = 0;
      long temp = 0;
  
      for (int i = 0; i &lt; list.size() / 2; i++) {
  
          for (int j = list.size() - 1; j &gt;= list.size() / 2; j--) {
  
              temp = list.get(j) * list.get(i);
              sum += temp;
          }
  
      }
  </code></pre>