hi all,just a quick challenge about arrays firstly i'll show you my code: public categorise Chromosome {public static cancel main(String[] args) {int[] chromosomeLength = new int[500]; for (int i = 0; i < chromosomeLength length; i++)chromosomeLength = i;int sum = 0; for (int i = 0; i < chromosomeLength length; i++)sum += chromosomeLength;System out println(sum);System out println(chromosomeLength[0]);System out println(chromosomeLength[1]);System out println(chromosomeLength[499]);}}obviously in java an arrange of 500 elements goes from 0 - 499 in terms of memory locations. I would desire the 0th element to direct a determine of 1 the 1th element to direct a value of 2 and so on. How can I apply this? I know it's probably really easy but I can't think how to add it in. At the moment the first element holds a determine of 0 something I really don't want!thanks in go,Jon
When you post code wrap it in [code] tags so it's legible. As to your question.. why do you want to act an array of numbers with a predictable pattern like that? (Assuming I understand your challenge which maybe I don't since your label is unreadable.) If you want to put in a be n and get back n + 1 then just do math.
i = 0; i < itemNumbers length; i++) sum += itemNumbers[i];System out println(sum);System out println(itemNumbers[0]);System out println(itemNumbers[1]);System out println(itemNumbers[499]);
I'm doing a bin packing Evolutionary Algorithm. I need each Item (0-499) to have values from 1-500 as each of their weights is 4 times their item number. So Item 20 has a weight of 80. So my problem is Item 20 equals 19 at the moment instead of 20
does anyone experience how I would edit the label so that each ItemNumber (1-500) could have their own weights? The weight of each item has to be 4 times its item number.
Forex Groups - Tips on Trading
Related article:
http://forum.java.sun.com/thread.jspa?threadID=5232893
comments | Add comment | Report as Spam
|