我肯定遗漏了一些非常明显的东西,但是我到处都找不到这个方法。
发布于 2011-02-10 20:41:54
数组没有indexOf()
方法。
也许这个Apache Commons Lang ArrayUtils
方法就是您要找的。
import org.apache.commons.lang3.ArrayUtils;
String[] colours = { "Red", "Orange", "Yellow", "Green" };
int indexOfYellow = ArrayUtils.indexOf(colours, "Yellow");
发布于 2011-08-16 19:26:04
对于原语,如果你想避免装箱,Guava为原语数组提供了帮助器,例如Ints.indexOf(int[]数组,int target)
发布于 2011-02-10 20:39:18
Java ArrayList
有一个indexOf
方法。Java数组没有这样的方法。
https://stackoverflow.com/questions/4962361
复制相似问题