I have the array of Strings, but I need to filter and create two arryas from one array, where can be all Items with character "A" and all Item with character "B".
List<String> coffeeMenu = ['Item A' , 'Item B', 'Item A', 'Item B', 'Item A', 'Item B'];
The suppoused output is:
['Item A','Item A','Item A']
['Item B', 'Item B', 'Item B'];
I have read that my tasks can be solved by using contains method, and i tried to do something like this:
if(coffeeMenu.contains('A')){
print(coffeeMenu);
}else{
coffeeMenu.contains('B');
print(coffeeMenu);
}
But as I said I need not only to ckeck if A nad B character are existed but also fall it apart in two arrays. How can I do that?
I will be glade if you help me