Arrays (toString) not output correctly
Posted
by
DiscoDude
on Stack Overflow
See other posts from Stack Overflow
or by DiscoDude
Published on 2010-06-14T20:51:31Z
Indexed on
2010/12/27
14:54 UTC
Read the original article
Hit count: 125
java
Hello,
Actually this tread is continuing from the other one. There wasn't enough characters to continue there. Anyway. the problem is that the output is "1(10) 2(23) 3(29)". Even though I could return string for the array values (10,23,29) and used string reference as 1, 2 and 3. My question is it possible to return index values 1,2,3 and as well as array values. Am I making an sense. Here is what I have done...
// int[] groups = {10, 23, 29}; in the constructor
String tempA = "";
String tempB = " ";
int[] temp = new int[4];
int length = groups.length;
for (int j = 0; j < length; j++)
{
temp[j] = groups[j];
tempB = tempB + "("+goups+")";
}
groups = temp;
Arrays.sort(coingroups);
for(int i = 1; i < groups.length;i++)
{
tempA = tempA+" "+(i)+ "("+groups[i]+")";
}
return tempA;
© Stack Overflow or respective owner