I fixed an endless loop by changing Integer to int in the following:
public class IntTest { public static void main(String[] args) { Integer x=-1
You can use Integer.intValue() to get the int value for comparison, if you truly need to use Integer at all.