Java中的二分查找方法,用于获取在数组中的下标
来源:互联网 发布:淘宝卖家开通花呗流程 编辑:程序博客网 时间:2024/05/20 05:23
继续上面地址中的问题,使单选项列表框默认选中前次选中的值。
问题:如果选中了一个选项,但是却点击了“取消”的Button,同样记录了选择的选项,输出值不变。
附上图
要做到输出值和下次打开单选项列表框时的默认选项相符,那就用到下面的东东了!
重载的binarySearch方法
public static int binarySearch(byte[] array, byte value) { /* compiled code */ }
public static int binarySearch(byte[] array, int startIndex, int endIndex, byte value) { /* compiled code */ }
public static int binarySearch(char[] array, char value) { /* compiled code */ }
public static int binarySearch(char[] array, int startIndex, int endIndex, char value) { /* compiled code */ }
public static int binarySearch(double[] array, double value) { /* compiled code */ }
public static int binarySearch(double[] array, int startIndex, int endIndex, double value) { /* compiled code */ }
public static int binarySearch(float[] array, float value) { /* compiled code */ }
public static int binarySearch(float[] array, int startIndex, int endIndex, float value) { /* compiled code */ }
public static int binarySearch(int[] array, int value) { /* compiled code */ }
public static int binarySearch(int[] array, int startIndex, int endIndex, int value) { /* compiled code */ }
public static int binarySearch(long[] array, long value) { /* compiled code */ }
public static int binarySearch(long[] array, int startIndex, int endIndex, long value) { /* compiled code */ }
public static int binarySearch(java.lang.Object[] array, java.lang.Object value) { /* compiled code */ }
public static int binarySearch(java.lang.Object[] array, int startIndex, int endIndex, java.lang.Object value) { /* compiled code */ }
public static <T> int binarySearch(T[] array, T value, java.util.Comparator<? super T> comparator) { /* compiled code */ }
public static <T> int binarySearch(T[] array, int startIndex, int endIndex, T value, java.util.Comparator<? super T> comparator) { /* compiled code */ }
public static int binarySearch(short[] array, short value) { /* compiled code */ }
public static int binarySearch(short[] array, int startIndex, int endIndex, short value) { /* compiled code */ }
其中用到了public static int binarySearch(java.lang.Object[] array, java.lang.Object value) { /* compiled code */ }
我有一个数组String[] strs,已知了其中的一个String value,想要获取value在数组中的index,就用到了上面这个方法:int index = binarySearch(strs,value);
------------------------------------------------------------------------------------------------------------
学习中遇到了这个问题,特此记下!
- Java中的二分查找方法,用于获取在数组中的下标
- 在数组中进行二分查找找出某数在数组中的下标
- angularjs ng-repeat 获取当前在数组中的下标
- 用二分法查找数组中的下标
- java中的 二分查找
- java中的二分查找
- Java数组-二分查找法用于元素插入有序数组,并获取元素插入的位置
- 有序数组中的二分查找
- 重复数组中的二分查找
- 符号表以及在有序数组中的二分查找
- N个有序整数数列已放在一维数组中,利用二分查找法查找整数m在数组中的位置,若找到,则输出其下标值;反之,则输出 “Not be found”
- VBA中的数组下标
- java中的数据结构--二分查找
- java中的二分查找算法
- 快速查找数组中的某个元素,并返回下标
- 二分查找 基于有序数组 返回下标
- java中的折半查找(二分查找)
- 已排序二维数组中的二分查找
- 就把这当作开始。
- Android源码中所使用到的设计模式design patterns
- GNU Radio中文入门教程V0.99
- java中的数据类型
- matlab图形句柄总结
- Java中的二分查找方法,用于获取在数组中的下标
- OO中对于23种设计模式的整理
- Nginx/Apache 对图片,css,js等优化,静态页面设置过期时间
- 2014年艺龙网校园招聘笔试总结
- AIR(iOS/Android)程序中控制设备方向
- 杂项
- Android SDK Platforms
- yy
- hdu1864