a simple learning array question
in
Programming Questions
•
2 years ago
I am attempting to get the names of a text string of the objects that are loaded in a two dimensional object array...
so..my beginner question is, can I not call like this on an array?
for (int i = 0; i < cols; i++) {
String rowsarray[] = mods.getSampleName[i];
textout.println(rowsarray[i]);
for (int j = 0; j < rows; j++) {
String columnsarray[] = mods.getSampleName[j];
textout.println(columnsrarray[j]);
}
}
textout.println(rowsarray[i]);
for (int j = 0; j < rows; j++) {
String columnsarray[] = mods.getSampleName[j];
textout.println(columnsrarray[j]);
}
}
thanks for the guidance
:)
edit:
//maybe this version seems more logical to me, ...but it still doesn't work..my probably equally misguided get method below. I'm sure this is very obviously wrong somewhere...
//
Module[][] mods;
//
for (int i = 0; i < cols; i++) {
String columnarray[] = mods[i].getSampleName;
textout.println(columnarray[i]);
for (int j = 0; j < rows; j++) {
String rowarray[] = mods[j].getSampleName;
textout.println(rowarray[j]);
}
}
String columnarray[] = mods[i].getSampleName;
textout.println(columnarray[i]);
for (int j = 0; j < rows; j++) {
String rowarray[] = mods[j].getSampleName;
textout.println(rowarray[j]);
}
}
//
//class Module method getSampleName
String getSampleName() {
SampleName = s;
return this.SampleName;
}
SampleName = s;
return this.SampleName;
}
//another attempt....what is the syntax for this?...ok..i think i'm counting it wrong, but i just want to understand the get syntax..
for (int i = 0; i < cols; i++) {
String columnarray[] = mods[i].getSampleName();
textout.println(columnarray[i]);
for (int j = 0; j < rows; j++) {
String rowarray[] = mods[j].getSampleName();
textout.println(rowarray[j]);
}
}
//String s holds the sample name parameter in the constructor
String getSampleName() {
return this.s;
}
return this.s;
}
1
