[英]Java Multiple Method Calls
My application has a methodA
that is executed for a service request. 我的应用程序有一个针对服务请求执行的
methodA
。 Now we would like to send a list of requests instead of single request and for every request methodA
has to be called or processed. 现在,我们希望发送一个请求列表,而不是单个请求,并且对于每个请求,必须调用或处理方法
methodA
I could put a basic loop and call the method like 我可以放一个基本的循环,然后像这样调用方法
public String findN(criteria criteriaList) {
.....................
for( int i = 0; i < reqList.length; i++ )
{
Req req = reqList[i];
methodA(req);
}
}
Is there a better programming approach then just looping? 有没有比循环更好的编程方法? Is there a design pattern that covers this aspect?
有没有涵盖此方面的设计模式?
for(Request req : reqList) {
MethodA(req);
}
Is the best Java offers currently. 是目前Java最好的产品。 More functional languages do this in one line, using methods like
.map
, .foreach
, etc. 更多的功能语言使用
.map
, .foreach
等方法在一行中做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.