String str[] = new String[5];
CSVReader read = new CSVReader(new FileReader("abc.csv"));
str = read.readNext();
str[3] = "A";
In the above code snippet, I am declaring array of strings of size 5. I am using OpenCSV to parse my CSV file. The CSV file has three columns. The statement str = read.readNext() stores values in str[0], str[1], str[2]. The problem is that after this statement is executed, the size of the array str is reduced to 3. Due to this str[3] throws ArrayIndexOutOfBounds exception. Why the size is reduced to 3 from 5 ?
strwith an entirely new array.