Happy Man
Happy Man

Reputation: 3

Type mismatch: cannot convert from element type Object to List

I got this error: "Type mismatch: cannot convert from element type Object to List" in "subLists" "and Type mismatch: cannot convert from element type Object to String" in "accList"

Code:

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;

Upvotes: 0

Views: 1574

Answers (1)

azro
azro

Reputation: 54148

You did not specify what type of object was in the different lists, you need to, the programm won't guess :

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

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

Also, better use Interfaces than Implementations to store the variable, easier to update (List<List<String>> rather than ArrayList<List<String>>

Upvotes: 1

Related Questions