Q:

Turning a list into an indexed array

I have a list of values in a text file, 
 People.txt[
 Name, ID, DOB, Sex
 Bill, 12, 12/12/1989, Male
 Cindy, 13, 12/11/1991, Female
 ]

I had originally read the values into a string then transformed the string into an array at the ',' value using 
 List<String> items = Arrays.asList(str.split("\\s*,\\s*")); 

but I want to try and find a way to either create an object containing the headings and sort them into lists or an array of associative arrays with indexes for all of the values.
I'm fairly rookie at Java and I can't figure out how to transform the values into an array with headings.

A:

 String[] lines = str.split("\n");
 String[] header = lines[0].split("\\s?,\\s?");

 List< String[] > data = new ArrayList< String[] >();
 for ( int i=1; i<lines.length; i++ ) {
     data.add( lines[i].split("\\s?,\\s?") );
 }

haven't run the code ... but should be enough to get the idea :)
you'll need to index data the same way as you index header since that is what you seemed to ask for e.g. you can wrap this in an object of your own :
class PeopleData implements Iterable<String[]> {

    final String[] headers;
    final List< String[] > data;

    public PeopleData(final String str) {
        String[] lines = str.split("\n");
        this.headers = lines[0].split("\\s?,\\s?");

        data = new ArrayList<String[] >();
        for ( int i=1; i<lines.length; i++ ) {
            data.add( lines[i].split("\\s?,\\s?") );
        }
    }

    public int size() {
        return headers.length;
    }

    public String[] getHeaders(int i) {
        return headers;
    }

    public String getHeader(int i) {
        return headers[i];
    }

    public String[] getRow(int i) {
        return data.get(i);
    }

    public String getData(int header, int i) {
        final String[] row = getRow(i);
        return row[header];
    }

    public String getData(String header, int i) {
        final int index = index(header);
        if ( index == -1 ) {
            throw new IndexOutOfBoundsException("header '" + header + "' not found");
        }
        return getData(index, i);
    }

    private int index(final String header) {
        for ( int i=0; i< headers.length; i++ ) {
            if ( header.equals( headers[i] ) ) return i;
        }
        return -1;
    }

    @Override
    public Iterator<String[]> iterator() {
        return data.iterator();
    }

}

