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
sweta kumari 55sweta kumari 55 

covert string to integer this list

public class ApexCollection {
    
public static void apexMethod(string a)
{
    
    String[] arr=new String[]{'A','B','C','D','A'};
        integer s1=integer.valueOf(arr);  
       System.debug( 'intVal value is ' + s1 );

error: Method does not exist or incorrect signature: void apexMethod() from the type ApexCollection.

I am getting error on this code, please response.
Shri RajShri Raj
public static void apexMethod(string a) {
    String[] arr = new String[]{'1', '2', '3', '4', '5'};
    List<Integer> intList = new List<Integer>();
    
    for(String s : arr) {
        Integer i = Integer.valueOf(s);
        intList.add(i);
    }
    
    System.debug('intList values are ' + intList);
}