wood burning stoves
The moose likes Beginning Java and the fly likes Errors - can't understand why.  HELP!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Errors - can Watch "Errors - can New topic

Errors - can't understand why. HELP!!!

Naf Rash
Ranch Hand

Joined: Feb 19, 2004
Posts: 85
I don't know why I keep getting these errors. I have looked at the coed and as far as I can see the variables that cause the errors to arise are within scope and to be honest the errors just don't seem to be making any sense.

class Clusteringclass {
distances dist = new distances();
double theRow = 1;
double theCoulmn =0;
double newRow = 1;

public Clusteringclass(){
private void obtainClusters(double distanceMatrix[][]){
int all;
//int i;
for (int i=0;i<distanceMatrix.length; ++i){
for (all = 1; all<distanceMatrix.length; ++all)
for (double checkDistanceVal = 100; checkDistanceVal > distanceMatrix[i][all] && distanceMatrix[i][all] !=0;
checkDistanceVal = distanceMatrix[i][all] )
//checkDistanceVal = distanceMatrix[i][all];/*This will hold the final value ie, the value with the smallest distance.*/
double row =(double)i;
double column = (double)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
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
++newRow;/*Only increment the row value because going to input the new values downwards. */

distanceMatrix = newArray;
return distanceMatrix;
[ March 05, 2004: Message edited by: Naf Rash ]
sever oon
Ranch Hand

Joined: Feb 08, 2004
Posts: 268
What errors? I think you forgot to post them with the code...
Also, can you directly cut'n'paste your code into your code tags so the indention is in place? It's very difficult to read it otherwise. (You don't have to enter a new post altogether--you're free to edit the one you already made, just click the notepad/pencil at the top of that post and edit away.)
Naf Rash
Ranch Hand

Joined: Feb 19, 2004
Posts: 85
Sorry forgot to mention the errors. They are:
Syntax error on token "row", ".", "[" expectedline 21
Syntax error on token "row", "]" expectedline 43
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
There are seveal syntax errors, and fixing one leads to the creation of others. I'll list some of the errors that need to be fixed.
1. double theCoulmn =0; // Should be double theColumn =0;

2. system.out.println(...); // Should be System.out.println(...);

3. newArray[newRow][theColumn] = Math.min(double [row][i], double [column][i]);
"double" is not the name of an array. I think you want Math.min(distanceMatrix[row][i], distanceMatrix[column][i]);

4. for (int i = 0; i < theDistanceMatrix.length; ++i){
There is no "theDistanceMatrix" ... should be "i < distanceMatrix.length".

5. Since you are using "theRow", "theColumn" and "newRow" as array indexes, they should be declared as "int", not "double".

6. Based on how you're using it, the line "for (all = 1; all<distanceMatrix.length; ++all)"
should probably be "for (all = 1; all<distanceMatrix[i].length; ++all) (do you really want to start with "all=1", or "all=0"?)

7. For some reason it doesn't like the line " double row =(double)i;" right after the "for" loop. Even if you are only doing one thing inside of a control statement (if, for, while), it's not a bad idea to enclose it in curly braces. Just uncomment out the line right before it, which is probably what you want to happen inside of the loop.

These are just syntax errors. Once you get it clean-compiled you can worry about the logic errors.
I agree. Here's the link: http://aspose.com/file-tools
subject: Errors - can't understand why. HELP!!!
It's not a secret anymore!