title: Difference between j = i + 1 and j = ++i;
body: <p>I get different results, in the inner for loop for(j = i + 1...) and for(j = ++i...) in the code below. Please can anyone explain what happens in the for loop, during the initialization?</p>
  
  <pre><code>    public class DuplicateElementsInArray {
  
      public static void main(String[] args) {
              String[] names = {"Java", "Python", "C++", "JavaScript", "Java",  "Ruby", "C"};
  
              //This is a worst  Solution
              for(int i = 0; i &lt; names.length; i++) {
                  //for(int j = i++; j &lt; names.length; j++) {
                  //for(int j = ++i; j &lt; names.length; j++) {
                  for(int j = i + 1; j &lt; names.length; j++) {
                      //System.out.println("j: " + j);
                      if(names[i].equals(names[j]))
                          System.out.println("duplicate element: " + names[i]);
                  }
              }
          }
      }
  </code></pre>