title: Changing a variable outside a for loop from within the loop
body: <p>In this situation an array nums has an undefined amount of integers in it and I'm trying to find the largest and print it. When I do this a is always printed as 0 because whatever is happening in the loop doesn't affect the a value outside of it. Anyone know how to fix this?</p>
  
  <pre><code>int a = 0;
  for(int i=0;i&gt;nums.length;i++){
    if(nums[i]&gt;a)
      a=nums[i];
    i++;}
  System.out.print(a);
  </code></pre>