英文:
Getting an Incompatible types error when using List as a parameter
问题
我有下面的这个方法,调用createInternalUserSearchClauses
时会引发错误:error: incompatible types: UserSearchClause cannot be converted to List<UserSearchClause>
。
createInternalUserSearchClauses
的签名明确接受一个List<UserSearchClause>
作为参数,而and
显然是一个List<UserSearchClause>
,那么为什么会出现这个错误?
public UsersPage find(List<UserSearchClause> and) {
List<UserSearchClause> internalAnd = createInternalUserSearchClauses(and);
}
private UserSearchClause createInternalUserSearchClauses(List<UserSearchClause> userSearchClauses) {}
英文:
I have this method below which causes the error error: incompatible types: UserSearchClause cannot be converted to List<UserSearchClause>
when trying to call createInternalUserSearchClauses
.
The signature for createInternalUserSearchClauses
clearly takes a List<UserSearchClause>
as the param and and
is clearly a List<UserSearchClause>
so why am I getting this error?
public UsersPage find(List<UserSearchClause> and) {
List<UserSearchClause> internalAnd = createInternalUserSearchClauses(and);
}
private UserSearchClause createInternalUserSearchClauses(List<UserSearchClause> userSearchClauses) {}
答案1
得分: 3
createInternalUserSearchClauses
的返回类型不是列表。
英文:
The return type of createInternalUserSearchClauses
is not a list.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论