假设我们可以将pub
匹配为
plot
我怎么能暗示一个" shouldNot"对于("name"="A" AND "name!="B")
等
BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("name","A"))
.mustNot(QueryBuilders.matchQuery("name","B"));
答案 0 :(得分:2)
您可以使用:
public class PercentEven {
public static void main(String args[]){
int count = 0;
int[] a={2, 5, 9, 11, 0}; // this can be dynamic.I tried diff values
double percent = 0.0;
if (a.length > 0){
for ( int i = 0; i < a.length; i++){
if ( a[i] % 2 == 0){
count++;
}
}
percent = (100*count/a.length);
}
System.out.println(percent);
}
}