【问题标题】:How do I compare a string variable to a string variable that is stored in a object that is in a arraylist in java [duplicate]如何将字符串变量与存储在java中arraylist中的对象中的字符串变量进行比较[重复]
【发布时间】:2016-02-18 08:07:50
【问题描述】:

比如说我有

String s = "hey"; 
...
List<FacebookPerson> list = new ArrayList<FacebookPerson>();

我想看看列表中的一个对象是否已经有“嘿”的参数

【问题讨论】:

  • 提示过早回答者:如果您怀疑有问题的代码示例应该包含泛型类型并且问题没有正确格式化这些示例,请查看edit 选项以查看原始示例。请记住,浏览器无法打印&lt;...&gt;,因为它会将其视为标签。

标签: java


【解决方案1】:
String s = "hey";
for (String temp : list) {
   boolean status = temp.toLowerCase().contains(s.toLowerCase());
   if (status)
       System.out.println("Match Found!");

}

试试这个。

【讨论】:

猜你喜欢
  • 2016-03-03
  • 2012-04-06
  • 1970-01-01
  • 2018-08-23
  • 2021-09-02
  • 2015-08-14
  • 1970-01-01
  • 2015-10-03
  • 1970-01-01
相关资源
最近更新 更多