The answer to this question can be opinion based. That means there can be positives as well as negatives for the answers.
Variant1 will be better in my opinion. It's the same thing with less code.
Unless I expect that the program would have to run on an older version of JVM. However, in that case this would be far from being the only compatibility issue.
So, the only reason not to use autoboxing is if it's not available.
Autoboxing does create objects which are not clearly visible in the code. So when autoboxing occurs performance suffers.
It is not appropriate to use autoboxing and unboxing for scientific computing, or other performance-sensitive numerical code. An Integer is not a substitute for an int; autoboxing and unboxing blur the distinction between primitive types and reference types, but they do not eliminate it.
Confused Equals
Autoboxing has brought with itself a lot of things that just are not obvious to a programmer. What would be the output of below code?
Long longWrapperVariable=2L ;
System.out.println(longWrapperVariable.equals(2));
System.out.println(longWrapperVariable.equals(2L));
Here is what the above code prints:
false
true
If you are wondering what happened above, 2 was boxed to Integer and hence equals could not compare it with Long. And 2L was boxed to Long and hence returned true.
OutOfMemoryError
A boxing conversion may result in an OutOfMemoryError if a new instance of one of the wrapper classes (Boolean, Byte, Character, Short, Integer, Long, Float, or Double) needs to be allocated and insufficient storage is available.
More reference: https://dzone.com/articles/autoboxing-and-its-pitfalls-1