Here is how my code is set up:
public String[] function(List<String[]> playerList){
i = 5
return playerList[i];
When I try to run this code, I get the error:
Array type expected; found: 'java.util.List<java.lang.String[]>'
I know I'm screwing something up by mixing my arrays and lists, what would be the right way of fixing this code, assuming I can't change my list input to an array?
You access an element at an index in a List with a call to List.get(int index) (not [], that is accessing an element in an array). Like,
return playerList.get(i);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With