【发布时间】:2015-06-09 21:55:55
【问题描述】:
我尝试使用带有 Arraylist 的二进制搜索,它给了我这样的信息:
Collections 类型中的方法 binarySearch(List>, T) 不适用于参数 (ArrayList, String)
代码如下:
ArrayList <Object> a = new ArrayList <Object> ();
String date = JOptionPane.showInputDialog(null, "Please enter the date.")
int index = Collections.binarySearch(a, date);
二分查找应该从包含多个日期的数组 (a) 中返回特定日期的位置。我做错了什么?
【问题讨论】:
-
请给我们看一下
a的声明。 -
如果您的问题得到解答,请记得给accept an answer。
标签: java binary-search