I have the following array data, representing first the vertical then the horizontal axis then a value.
private static final String[] xy_data = {
"000", "010", "020", "030", "049", "050", "060", "070", "080",
"100", "110", "120", "135", "142", "150", "160", "178", "180",
"200", "210", "220", "231", "246", "253", "260", "270", "280",
"300", "313", "320", "330", "340", "350", "360", "370", "388",
"400", "410", "426", "439", "440", "457", "460", "470", "480",
"500", "510", "521", "530", "540", "550", "563", "577", "585",
"603", "618", "620", "630", "645", "650", "661", "670", "680",
"700", "710", "720", "734", "740", "752", "760", "770", "780",
"807", "812", "820", "833", "840", "851", "864", "870", "880"
};
I can then parse this array using:
static int[][] parseProblem(String[] xy_data) {
int[][] problem = new int[9][9];
for (int n = 0; n < xy_data.length; ++n) {
int i = Integer.parseInt(xy_data[n].substring(0, 1));
int j = Integer.parseInt(xy_data[n].substring(1, 2));
int val = Integer.parseInt(xy_data[n].substring(2, 3));
problem[i][j] = val;
}
return problem;
}
I then use this data to solve as Suduko puzzle using back tracing.
How do I set the new variable into the array (once calculated)? Do I need the row numer then simply setValue = newValue. This value would then need to passed to a jTextField on the GUI also preferably in the same method.
I previously posted this on yahoo answers but advised to look at:
Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
Allthough this page explains arrays it doesnt advise how to update an existing array element value.
Thanks in advance. :)
How do I update an array value (Java)?
Started by paulusyoungus, Jun 05 2010 08:34 AM
1 reply to this topic


Sign In
Create Account

Back to top









