I am trying to convert my string to int so that I can sum the values.
- The original value is "GBP 1.00 GBP 500.00";
- I need to split it and remove GBP so that the only remaining are integer values (1.00, 500.00) and store it in List.
- Now, I want to convert it to List so I can add the values: 1.00 and 500.00 equals 501.00.
import java.util.List;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.function.Function;
public class Main { 
  public static void main(String[] args) { 
    String num = "GBP 1.00 GBP 500.00";
        List<String> al = new ArrayList<String>(Arrays.asList(num.split(" ")));
        al.removeIf(n -> (n.charAt(0) == 'G'));
        
        
        System.out.println("Num: "+num);
        System.out.println("Al: "+al);
        System.out.println(al.get(0));
        System.out.println(al.get(1));
        System.out.println(al.get(1)+al.get(0));
        
        //---Convert List<String> to List<Int>- to add the values------------------//
       System.out.println("Convert List<String> to List<Int>");
       //Code here
        
  } 
}
//Result
Num: GBP 1.00 GBP 500.00
Al: [1.00, 500.00]
1.00
500.00
500.001.00
