Java - Type mismatch: cannot convert from element type Object to String
java
Solution
try this :
public List<String> customPrefixes(PermissionUser u)
{
List<String> returnlist = new ArrayList<String>();
for (String k : u.getAllPermissions().keySet()) {
List<String> perms = (List<String>)(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 `"<String>"` in the List declaration
Problem
I'm having this error: Type mismatch: cannot convert from element type Object to String This is the code in error: ``` public List<String> 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; } ```