Hi,
I'm having some problems with some code I've written- I keep getting errors.I have had a look at the code myself but think that a new pair of eyes may be needed beacuse I probably have made a stupid mistake somewhere but can't seem to find it. Just to provide you with some information - this class is used by another class and it obtains an array from another class also. The errors I'm receiving are:
- Syntax error on keyword "public"; ";", "," expectedline 10
- all cannot be resolvedline 20
- Syntax error on token "row", "]" expectedline 38
PLEASE HELP. The code is:
class Clusteringclass {
distances dist = new distances();
double theRow = 1;
double theCoulmn =0;
double newRow = 1
public Clusteringclass(){
dist.getMatrix();
}
private void obtainClusters(double distanceMatrix[][]){
for (int i=0;i<distanceMatrix.length; ++i){
for (int all = 1; all<distanceMatrix.length; ++all)
for (double checkDistanceVal = 100; checkDistanceVal > distanceMatrix[i][all] && distanceMatrix[i][all] !=0
checkDistanceVal = distanceMatrix[i][all];/*This will hold the final value ie, the value with the smallest distance.*/
double row = i;
double column = all;/*These assignments ensure that the corresponding row and column numbers are stored for the
shortest value.*/
}
}
public double[][] addElement(double[][] distanceMatrix, double row, double column ){
double[][] newArray = new double [distanceMatrix.length - 1][distanceMatrix.length - 1];/*Creates a brand new array of greater
length*/
for ( int i = 0; i < distanceMatrix.length; i++){
system.out.println (i+"\n");
if (i != row && i != column){/*As long as the element of distance matrix being covered is not*/
newArray[i - 1] = distanceMatrix[i];/*Assigns elements of the distance matrix to the new Array. use -1 because obviously
the array size will decrease since the rows that are of the shortest distance will be amalgamated into 1. */
}
}
for (int i = 0; i < theDistanceMatrix.length; ++i){
newArray[newRow][theColumn] = Math.min(double [row][i], double [column][i]);/*Puts the minimum value into the new array at the
beginning.*/
++newRow;/*Only increment the row value because going to input the new values downwards. */
}
distanceMatrix = newArray;
return distanceMatrix;
}
}