A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© lizf2010 中级黑马   /  2015-7-29 20:45  /  188 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. public class Hellojava {

  2.         public static void main(String[] args) {

  3.                 show(1);
  4.                     }
  5.                     public static void show(Integer i){
  6.                             System.out.println("Integer is run");
  7.                     }
  8.                     public static void show(int i){
  9.                             System.out.println("int is run");
  10.                     }
  11. }
复制代码
如上所示,当我们第一次运行这段代码的时候输出的是int is run,但是当注释掉第二个show方法后,也能运行,但是输出结果为Integer is run,即自动转型调用的第一个show方法,为什么第一次运行时没有自动转型调用第一个show方法呢,JVM是怎么判断要不要转型的呢?

1 个回复

倒序浏览
有用 ,多谢了。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马