which Java version are you using? For this code example you need 1.5 or greater!
The problem is you're calling a method equals() on variable a2 which is a primitive int. Because primitive types like int aren't first class objects, you can't call a method on such variables. This is only possible to do with reference variables which point to an object.
With an older version of Java you'll have to use the wrapper object types like Integer for this code to work:
If you're using Java >= 1.5 this is done automatically for you with a new feature called autoboxing. Autoboxing converts a variable transparently between the primitive type (like int) and its corresponding wrapper type (like Integer).