User Story
Convert all the elements of this list to uppercase.
List<string> Fruits = new List<string>{'Banana', 'Apple', 'Cherry'};
Expected Outcome
DEBUG|(BANANA, APPLE, CHERRY)
Code
Solution 1:
List<string> Fruits = new List<string>
{'Banana', 'Apple', 'Cherry'};
for (String i : Fruits) {
Fruits.set(Fruits.indexof(i), i.toUpperCase());
}
System.debug(Fruits);
Solution 2:
List<string> Fruits = new List<string>{'Banana', 'Apple', 'Cherry'};
List<string> FruitsinUpperCase= new List<string>();
for(String fruit : Fruits){
fruit=fruit.toUppercase();
FruitsinUpperCase.add(Fruit);
}
System.debug(FruitsinUpperCase);
Video
Video does not exists.