function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NishaCNishaC 

how to Sum the string number

i have a variable name countdays

String Countdays = ' ' ;

 

in debug it is having values like this

========CountDays===========40,40,40,39,39,39 and so on

 

how to sum it and get the total i.e = 40+40+40+39+39+39....... = 

 

please share your ideas with me

MagulanDuraipandianMagulanDuraipandian

Convert it to Integer and them Sum it.      

        String a;    
        Integer d = Integer.ValueOf(a);

 

If this is the solution, kindly mark this as the solution.

Anil MeghnathiAnil Meghnathi

Nisha

This may solve your issue

 

 

String allNumber="10,20,20,10";

integer tot=0;

List<String> sinNum =allNumber.split(',');
for(String d:sinNum)

{

tot=tot+Integer.ValueOf(d);
}

 

May this solve your issue

Thanks

Anil