I'm working with string value like this String result "aa,bb,cc,dd,ee".
And already split it into aa bb cc dd ee with
qrList = result.getContents().toString().split("\\,");
List<String> resultToString= new ArrayList(Arrays.asList(qrList));
Then I create four ArrayLists.
ArrayList<String> strA = new ArrayList();
ArrayList<String> strB = new ArrayList();
ArrayList<String> strCD = new ArrayList();
ArrayList<String> strE = new ArrayList();
When I use this code below to store string into each new ArrayList.
for(int count=0; count<resultToString.size(); count++){
//separate string to array list
if(count%5==0){
strA.add(resultToString.get(count));
}else if(count%5==1){
strB.add(resultToString.get(count));
}else if(count%5==2||count%5==3){
strCD.add(resultToString.get(count));
}else if(count==4){
strE.add(resultToString.get(count));
}
The correct result would be
- strA stored aa
- strB stored bb
- strCD stored cc and dd
- strE stored ee
It doesn't work because I only get the index value at 0 (strA stored aa).
What should I do to improve my code?
count==4must be true for your given input