ArrayIndexOutOfBoundsException: 0 help me....

G

gbattine

Hi guys,
i've developed a java application that give me this error in run-time

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Riga.main(Riga.java:51)

Can you help me to solve it?Thanks...

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Riga{
private static String fileName = "Dato2.txt";
private String geneid=null;
private double[] values=new double[5];
private static int row=0;
private static int numberOfNumericColumns=0;
private static int col=0;

public Riga(String idGene,double[] x ) {
this.geneid=idGene;
this.values=x;
}
public String getgeneid(){
return this.geneid;
}
public void setgeneid(String idGene){
this.geneid=idGene;
}
public double[] getvalues(){
return this.values;
}
public void setvalues(double[] x){
this.values=x;
}
public void id(){
System.out.println("La linea è"+geneid+values);
}


public static void main(String[] args) throws IOException {
FileReader reader=new FileReader(fileName);
BufferedReader br = new BufferedReader(reader);
ArrayList <Riga> rows = new ArrayList <Riga>();
String line = null;
double[] y=new double[(numberOfNumericColumns)];
while ((line = br.readLine()) != null) {
line = line.replace (',', '.');
row++;

StringTokenizer st = new StringTokenizer(line);
numberOfNumericColumns = (st.countTokens()-1);
col=(numberOfNumericColumns+1);
String x=st.nextToken();
for (int i=0;i<numberOfNumericColumns;i++){
y=Double.parseDouble(st.nextToken());
}
Riga z=new Riga(x,y);
rows.add(z);
}

for(int i=0;i<row;i++)
rows.get(i).id();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top