csv file data structure java

Solutions on MaxInterview for csv file data structure java by the best coders in the world

showing results for - "csv file data structure java"
Nadir
19 Nov 2016
1HashMap<String, List<String>>
2//csv file has 3 columns first column can be used as key 
Alex
29 May 2016
1List<List<String>> csv = new ArrayList<>();
2//Generic answer
Gus
14 Oct 2018
1if you have a lot of holes in you CSV use the comparable as your coordinate
2public class Coordinate implements Comparable<Coordinate> {
3    public int row;
4    public int column;
5    public Coordinate(int r, int c) {
6        row = r;
7        column = c;
8    }
9
10    @Override
11    public int compareTo(Coordinate o) {
12        int r = Integer.compare(row, o.row);
13        if(r == 0) {
14            r = Integer.compare(column, o.column);
15        }
16        return r;
17    }
18
19    public boolean equals(Object o) {
20        if(o instanceof Coordinate) {
21            Coordinate c = (Coordinate)o;
22            return row == c.row && column == c.column;
23        }
24        return false;
25    }
26}
27