簡體   English   中英

類型不匹配:無法從元素類型對象轉換為列表

[英]Type mismatch: cannot convert from element type Object to List

我收到此錯誤:“ Type mismatch: cannot convert from element type Object to List" in "subLists"Type mismatch: cannot convert from element type Object to String""accList"

碼:

ArrayList subLists = new ArrayList();

for (List accList : subLists) {
        service.submit(() -> {
            for (String account : accList) {
                accounts.remove(account);
                String[] split = account.split(":");
                String email = split[0];
                String password = split[1];
                AuthResult result = null;

您沒有指定不同lists的對象類型,您需lists ,程序不會猜測:

List<List<String>> subLists = new ArrayList<>();  

for (List<String> accList : subLists) {
    service.submit(() -> {
        for (String account : accList) {
// ...

另外,與Implementations相比,更好地使用Interfaces來存儲變量,更易於更新( List<List<String>> rather than ArrayList<List<String>>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM