Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1460 :

Posted: Sun Jul 25, 2021 6:18 pm
by enthunoob

Code: Select all

public class ParamTest {
  public static void printSum(int a, Integer b){
      System.out.println("In int Integer "+(a+b));
  }
  
  public static void printSum(Integer a, Integer b){
      System.out.println("In Integer Integer "+(a+b));
  }
  
  public static void printSum(Integer a, int b){
      System.out.println("In Integer int "+(a+b));
  }
  
  public static void main(String[] args) {
      printSum(1, 2);
  }
}
When called with printSum(Integer.valueOf(1), 2) it works and prints In Integer in. But when this code runs, the JVM cant figure out what method to choose. Is that just the online compiler I'm using (https://www.programiz.com/java-programm ... -compiler/)?

Re: About Question enthuware.ocajp.i.v8.2.1460 :

Posted: Fri Aug 13, 2021 5:05 am
by admin
Try it with regular Oracle jdk and see what happens. Also, please post exact code that you tried.