Passing int to a method taking Integer as parameter?
java
Solution
Yes, it is OK, it will be auto-boxed.
The reverse is also OK and is called auto unboxing.
More info here:
Autoboxing and Unboxing
Problem
Is it Ok to pass int to a method which is taking Integer as parameter. Here is the code ``` public class PassingInt { public static void main(String args[]) { int a = -1; passIntToInteger(a);//Is this Ok? } private static void passIntToInteger(Integer a) { System.out.println(a); } } ```