Exception in thread "main" java.lang.CLassException

Joined
Jun 13, 2007
Messages
1
Reaction score
0
Hi everyone , I am getting
" Exception in thread "main" java.lang.ClassCastException " error
when I run the following code:


private float[][] getDistancesTable(LinkedList Betas, byte metrics) {


Beta_Sheet b1 = new Beta_Sheet();
Beta_Sheet b2 = new Beta_Sheet();

b1 = null;
b2 = null;
int betacount = Betas.size(); //the size of the array
// System.out.println("the metrics is" + metrics);

float[][] distances = new float[betacount][betacount]; //two dimentional array
//Beta_Sheet[] bs = (Beta_Sheet[]) Betas.toArray(new Beta_Sheet[betacount]); //creates an 3 dimentional array of betas
//System.out.println("the length of the array is" + bs.length);
// TODO check if the table is already in the database
for (int i = 0; i < betacount; i++) {

//b1 = bs;

b1 = (Beta_Sheet)Betas.get(i); //
System.out.println(" I am still here");
b1 =(Beta_Sheet) Betas.get(i);


for (int j = i + 1; j < betacount; j++) {
//b2 = bs[j];
b2 = (Beta_Sheet)Betas.get(j);
switch (metrics) {
case _AVERAGE_DISTANCE_REF:

distances[j] = b1.DistanceWithBeta(b2);

break;
case _GPOINT_DISTANCE:
distances[j] = b1.DistanceToCentre(b2);
break;
case _MIN_DISTANCE:
System.out.println("i'm in the minimum distance option");
distances[j] = b1.MinimumDistance(b2);
break;
case _AVERAGE_DISTANCE:
distances[j] = b1.Distancetobeta(b2);
break;
default:
// do nothing
break;
}
}
}
return distances;
}

Exact Error is:


Exception in thread "main" java.lang.ClassCastException: java.lang.String
at JFILES.BetaNeighboursFinder.getDistancesTable(BetaNeighboursFinder.java:82)
at JFILES.BetaNeighboursFinder.main(BetaNeighboursFinder.java:131).

I think the error is at this line:
b1 = (Beta_Sheet)Betas.get(i); //

But I seriously don't know how to solve it, your help is really appreciated

Best regards,
Zia
 

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

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top