All right so I have agonized over this code for the past hour or so. This is the code for the class in question.
public DistanceProject(String costs, String firstString,String secondString)
{
Scanner scan = new Scanner(costs);
copyCost = scan.nextInt();
replaceCost = scan.nextInt();
deleteCost = scan.nextInt();
insertCost = scan.nextInt();
twiddleCost = scan.nextInt();
killCost = scan.nextInt();
stringFirst = firstString;
stringSecond = secondString;
maxFirst = stringFirst.length();
maxSecond = stringSecond.length();
costArray = new int[maxFirst+1][maxSecond+1];
operations = new String[maxFirst+1][5];
costArray2 = new int[maxFirst+1][maxSecond+1];
operations2 = new String[maxFirst+1][maxSecond+1];
System.out.println("This is MaxSecond: " + maxSecond);
}
private int copyCost;
private int twiddleCost;
private int replaceCost;
private int insertCost;
private int killCost;
private int deleteCost;
private String stringSecond;
private int maxFirst;
private int maxSecond;
private String stringFirst;
private int[][] costArray;
private String[][] operations;
private int[][] costArray2;
private String[][] operations2;
private int distanceMoves;
private int finalCost;
private int count;
private static final int LARGE_NUMBER = 10000000;
}
But after running this code and calling the constructor, it seems that the 2nd dimension for all the arrays that are declared in the class. I was wondering if there was any particular reason as to why this array declaration is failing so hard. The print statement does actually output a valid number if given input.
If you want to run this yourself, the input is supposed to look like this:
6 ints a row (0 15 15 10 10 30) String (anything) String (String2)
My test input (that failed) was: 0 15 15 10 10 30 anything know
Here are the screenshots of what happens when I run it on my computer: Before:
After: Eclipse does a good job of highlighting what I mean in the second screenshot. The first picture shows that it has a value right before going on to declare the costArray without a second dimension.