Integer dd=3;
System.out.println("1,3,5,4,6".indexOf(dd.intValue()));
System.out.println("1,3,5,4,6".indexOf(dd));
System.out.println("1,3,5,4,6".indexOf(3));
System.out.println("1,3,5,4,6".indexOf('3'));
System.out.println("1,3,5,4,6".indexOf(3+""));
System.out.println("1,3,5,4,6".indexOf(dd.toString()));
得到的结果为:
-1
-1
-1
2
2
2
由此可以看出使用String.valueOf 方法时候需要转化为 char、或者String类型