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?
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 < names.length; i++) {
//for(int j = i++; j < names.length; j++) {
//for(int j = ++i; j < names.length; j++) {
for(int j = i + 1; j < names.length; j++) {
//System.out.println("j: " + j);
if(names[i].equals(names[j]))
System.out.println("duplicate element: " + names[i]);
}
}
}
}