Java - Type mismatch: cannot convert from element type Object to String

后端 未结 2 330
别那么骄傲
别那么骄傲 2020-12-21 08:24

I\'m having this error:

Type mismatch: cannot convert from element type Object to String

This is the code in error:



        
2条回答
  •  遥遥无期
    2020-12-21 09:07

    try this :

    public List customPrefixes(PermissionUser u)
      {
        List returnlist = new ArrayList();
        for (String k : u.getAllPermissions().keySet()) {
          List perms = (List)(u.getAllPermissions()).get(k);
          for (String s : perms) {
            String[] split = s.split(".");
            if ((split.length >= 3) &&
              (split[0].equalsIgnoreCase("plugin")) &&
              (split[1].equalsIgnoreCase("prefix"))) {
              returnlist.add(split[2]);
            }
          }
    
        }
    
        return returnlist;
      }
    

    You were missing "" in the List declaration

提交回复
热议问题