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()));
获得的结果为:java
-1 -1 -1 2 2 2
由此能够看出使用String.valueOf 方法时候须要转化为 char、或者String类型 code