خرید بک لینک

Vote count: 0

Why the bar with int i signature is called?

public class Test {
  public static void main(String[] args) {
    bar(5);  // What type of the integer "5"?
  }

  public static void bar(short i) { 
    System.out.println("short");
  }

  public static void bar(int i) { 
    System.out.println("int");    
  }

  public static void bar(long i) { 
    System.out.println("long");
  }
}

I've checked the Oracle's documents 15.12. Method Invocation Expressions and 15.28. Constant Expressions, while still have no idea.

Could someone explain the type of the constants expression? Like the type of "5" above?

Thanks!

asked 52 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 6 ارديبهشت 1395 ساعت: 11:29

صفحه بندی