我正在编写一种方法来查找数组是否有重复项。我遇到了equals方法的一些问题,粗线的错误。我可以做出任何调整吗?
以下是我的部分代码:
public boolean duplicate(){
for (int i=0; i<data.length; i++){
for (int j=i+1; j<data.length; j++){
**if (data.get(i).equals(data.get(j)){**
return true;
}
}
}
return false;
}
答案 0 :(得分:4)
数组没有onDestroy
方法。相反,他们使用public class ProgressDialogHelper {
ProgressDialog mProgressDialog;
public ProgressDialogHelper() {
}
public ProgressDialogHelper(Context context, String title, String message) {
mProgressDialog = new ProgressDialog(context);
mProgressDialog.setTitle(title);
mProgressDialog.setMessage(message);
mProgressDialog.show();
}
public ProgressDialog getProgressDialog() {
return mProgressDialog;
}
public void setProgressDialog(ProgressDialog mProgressDialog) {
//make sure the previous dialog is hidden
hide();
this.mProgressDialog = mProgressDialog;
}
public void show() {
if (mProgressDialog != null && !mProgressDialog.isShowing()) {
mProgressDialog.show();
}
}
public void create(Context context, String title, String message) {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
mProgressDialog = ProgressDialog.show(context, title, message);
}
public void hide() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
}
public void onDestroy() {
hide();
}
}
语法:
get(int)
答案 1 :(得分:2)
SELECT
date_hour.hour,
COUNT(my_data.log_hour) AS count
FROM
date_hour
LEFT JOIN my_data ON date_hour.hour = my_data.log_hour
WHERE
date_hour.hour >= '2015-05-01 00:00:00' AND
date_hour.hour < '2015-05-02 00:00:00' AND
my_data.log_hour >= '2015-05-01 00:00:00' AND
my_data.log_hour < '2015-05-02 00:00:00'
GROUP BY
date_hour.hour
ORDER BY
date_hour.hour
;
应该用于data.get(i)
而不是数组应该是List
。
这将为您提供编译错误,data[i]
可以通过Array
索引访问,并且没有任何[]
方法。