You appear to have forgotten how the
code button works. But this time, I'll correct it for you and your code will look a lot better

moe ham wrote:Hello, I am writing a function that loads up data from a csv file and poppulates the data in an array list . . .
Why do you want a List? Why don't you have a Player class instead, and you can create a Player object for each line.
. . . I want to change the arraylist variable to be a public static . . .
That would be very bad design. Making a field public, especially something mutable like a List, is inviting trouble because other code can modify its state without your knowing about it. And making a field
static means there is only one instance of it, so you are going to add all your players to the same List.
. . . This is my load file function just in case:
. . .
Have you been taught to read a file like that? Don't close the file like that; use
try with resources instead. Actually I wouldn't use a File reference nowadays.
In which case I am assuming that you are processing all those lines in the Player constructor. I haven't allowed for any exceptions that might be thrown because of a malformed line in your file. There are all sorts of alternatives, including:-
1: Create the List with the lines() method of the buffered reader. See below.2: Give the Player class a factory method taking a line from your csv file as a parameter.How can you get a split
String being
null? I don't think you can. You can get an empty String: don't
test for
text.length() == 0 but for
text.isEmpty().