From the course: Data Science for Java Developers

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Converting strings to data objects

Converting strings to data objects - Java Tutorial

From the course: Data Science for Java Developers

Converting strings to data objects

- All right. So now let's actually implement this parse person static method here. So what we're basically going to do this string is going to be one of the lines that we loaded from here. So if you take a look at these here it's basically a comma-separated string. And what we're going to want to do is split this string into basically a list of strings. And then we're basically just going to pull the individual attributes out based on their position in the string, based on their index that is, so what we're going to want to do now is assuming we have the data string which is going to be a line of our text file. We're going to start off by saying List String fields = dataString .split and we're going to split it by a comma and we're going to need to do new Array List Arrays.asList since this returns an array of strings instead of a list like we want. And now that we have our array list of fields which is…

Contents