Reputation: 125
I have a arraylist containing values like [ addidas 5 100 , nike 10 300 , woodland 4 800] so if i print am gettinh result as
value1 :: adidas
value2 :: 5
value3 :: 100
result has to be like
value1 :: adidas,nike,woodland
value2 :: 5,10,4
value3 :: 100,300,800
ArrayList<String> array;
int j = 0;
String[] parts;
String value1;
String value2;
String value3;
for (j = 0; j <= array.size(); j++) {
parts = array.split(" ");
value1 = parts[0];
value2 = parts[1];
value3 = parts[2];
System.out.println("value1::" + value1);
System.out.println("value2::" + value2);
System.out.println("value3::" + value3);
}
Upvotes: 0
Views: 110
Reputation: 124225
Since this looks like homework there will be no code here.
There is one error in your code and few in logic.
split
can be invoked on String
so first you should get
that string from your array listUpvotes: 4