This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.

hi i am having a vector. i want to store the first value in the vector as "A", second as "B" and third as "c". The fourth value should again be set as "a" and so on.

eg

A[0] =vector.elementAt(0); B[0]=vector.elementAt(1); c[0]=vector.elementAt(3); a[1]=vector.elementAt(4); and so on... Please let me know how to do this.

i am having a vector. i want to store the first value in the vector as "A", second as "B" and third as "c". The fourth value should again be set as "a" and so on.

int[] a = new int[arraySize]; int[] b = new int[arraySize]; int[] c = new int[arraySize]; int aCount = bCunt = cCount = 0;

for each element in vector indexed by i; range 0 to size -1 { currElement = vector.element at i; if(i % 3 == 0) { a[aCount ++] = currElement; } else if (i % 3 == 1) { b[bCount ++] = currElement; } else { c[cCount ++] = currElement; }

int[] a = new int[arraySize]; int[] b = new int[arraySize]; int[] c = new int[arraySize];

Below is a solution to compute right array size. In case of 10 elements you need three arrays with 4, 3, 3 elements respectively In case of 11 elements you need three arrays with 4, 4, 3 elements respectively In case of 12 elements you need three arrays with 4, 4, 4 elements respectively

So the ArraySize can be different for all arrays. Say aArraySize, BArraySize, cArraySize

After dividing the size by 3 you get a fraction, If this fraction is zero (3/3), aArraySize = bArraySize = cArraySize = size/3; If this fraction is .33 (1/3) or less than .5 aArraySize = size/3 + 1; bArraySize = cArraySize = size/3; If this fraction is .66(2/3) or greater than .5 aArraySize = bArraySize = size/3 + 1; cArraySize = size/3;

To find the fraction you can do

fraction = size/3 - (int)size/3

[ December 21, 2005: Message edited by: jiju ka ] [ December 21, 2005: Message edited by: jiju ka ]