Chris Lenney

Greenhorn
+ Follow
since Mar 01, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Lenney

lol no, java is my first language, im just a bit slow. Thanks for your help, i'll put it inside another loop. Cheers
16 years ago
I have 2D array called grid which in column [0] has string in the format 01/03/2003, I don't want to deal with date formats as im only concentrated on the year, therefore i use substring and compare it to the year in question (as seen below).

My question is, how come the if statement only seems to iterate once? It should iterate a fair few times as the first 30 dates are "2003".

if (grid[row][0].substring(6,10).equals("2003")) {
out03.write(grid[row][1] + "\n");
System.out.println(row + "\n");
row ++;
}

Thanks, Chris
16 years ago
Thank you very much for all your comments, very helpful, looks like its 2D arrays. Can you just answer one last thing, I have the following problem:

int[] array1 = new int[20];
String num = "1";
String str = "array" + num; //making str = array1

How can i reference array1 using the String 'str'
18 years ago
Thanks for the quick reply, I shouldn't of written so much, what i really want to know is how arrays can be created in a loop? Can I create a loop which takes in value (say 20) and then creates 20 arrays?
18 years ago
I have an array called chromosomes of 20 Strings:
String chromosomes = [chromosome0,chromosome1,chromosome3... chromosome19]
I wish to loop through this array creating integer arrays of each String. The following code isn't valid due to incompatible types:

for (int i = 0; i < 20; i ++) {
String current = chromosomes[0];
current = new int[500];
}

How can i name the desired integer arrays with each of the 20 Strings in the chromosomes array? I cannot hard code the names in because in practise there will be an unknown number of them!
18 years ago