Tag Archives: operators

Java

Inconsistent Java operators

Look at this example:

public class OperatorTest {
	public static void main(String[] args) {
		Integer i1 = 1;
		i1 = i1 + + + + + 1;
		System.out.println(i1);
		int i2 = 1;
		i2 = i2 + + + + + 1;
		System.out.println(i2);
		String s = "s";
		s = s + + + + "t";
		System.out.println(s);
	}
}

What is wrong with this code? Does it compile? read more »