+ 3
Can someone explain the difference between these two?
String numTest = "10"; Integer result1 = 10 + Integer.parseInt(numTest); Integer result2 = 10 + Integer.valueOf(numTest); System.out.println(result1); // outputs 20. System.out.println(result2); // outputs 20. what's the difference or secret behind them?
2 Answers
+ 18
there is difference in there return type
1)Integer.valueOf (String) returns Integer object
2)Integer.parseInt (String) returns primitive Integer type (int)
+ 1
now I get itđ. thanks