我有一个字符串
/*Here, C++ program constructor in struct*/
#include <iostream>
using namespace std;
struct hello
{
public: //by default also it is public
hello();
~hello();
};
hello::hello()
{
cout<<"calling constructor...!"<<endl;
}
hello::~hello()
{
cout<<"calling destructor...!"<<endl;
}
int main()
{
hello obj; //creating a hello obj, calling hello constructor and destructor
return 0;
}
我有一个arraylist
UITextField
现在我想使用这个arraylist从这个字符串中搜索。我怎么能不使用for循环呢?
答案 0 :(得分:1)
使用Java 8流:
list.stream()
.filter(s -> string.contains(s))
.forEach(System.out::println);
答案 1 :(得分:0)
您必须使用String.compare()
功能逐一检查。
这是你要问的吗?
答案 2 :(得分:0)
for (String x : list) {
if(string.contains(x)) {
System.out.print(x);
}
}
答案 3 :(得分:0)
// Use JAVA 8 feature
String str = "I would loved to be the part of cricket team";
ArrayList <String> list = new ArrayList();
list.add("part");
list.add("bend");
list.add("bet");
list.add("bear");
list.add("beat");
list.add("become");
list.add("begin");
boolean anyMatch = list.stream().anyMatch(s -> s.contains(str));