【发布时间】:2012-10-23 20:12:53
【问题描述】:
这是我的一段代码:
ArrayList<String> Alist= new ArrayList<String>();
ArrayList<String> Blist= new ArrayList<String>();
Alist.add("gsm");
Alist.add("tablet");
Alist.add("pc");
Alist.add("mouse");
Blist.add("gsm");
Blist.add("something");
Blist.add("pc");
Blist.add("something");
所以我有两个数组列表,我想比较所有项目并检查它们是否不等于以及是否要仅打印不等于的项目 .
所以我做了这样的事情:
http://postimage.org/image/adxix2i13/ 抱歉图片,但是当我在这里发布一个 for 循环时,我遇到了某种错误。
结果是:
not equals..:tablet
not equals..:pc
not equals..:mouse
not equals..:gsm
not equals..:tablet
not equals..:pc
not equals..:mouse
not equals..:gsm
not equals..:tablet
not equals..:pc
not equals..:mouse
not equals..:gsm
not equals..:tablet
我只想打印示例中不相等的 2 个,它们是 gsm 和 pc
not equals..:gsm
not equals..:pc
【问题讨论】:
-
好吧,我看不到图像。发布代码时会遇到什么错误?我认为您应该尝试再次发布它。
-
我不明白为什么“gsm”和“pc”是“不相等”的项目。
标签: java string arraylist compare