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
Roger VandewaterRoger Vandewater 

Assign value to list of ints within inner class

I'm having trouble assigning vlues to a list on integers defined in an inner class. I'm trying to assign the value 243 to ArrayOfInt.int_x.

public class wsCsmtpNet201406 {

    public class ArrayOfInt {
        public Integer[] int_x;
        private String[] int_x_type_info = new String[]{'int','https://ws.xxxx.net/2014/06',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'https://ws.xxxx.net/2014/06','true','false'};
        private String[] field_order_type_info = new String[]{'int_x'};
    }
}
Pankaj_GanwaniPankaj_Ganwani
Hi Roger,

Did you try with initializing the array and then perform assignment?

public class wsCsmtpNet201406 {

    public class ArrayOfInt {
        public Integer[] int_x = new Integer[]{234, 333,90};
        private String[] int_x_type_info = new String[]{'int','https://ws.xxxx.net/2014/06',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'https://ws.xxxx.net/2014/06','true','false'};
        private String[] field_order_type_info = new String[]{'int_x'};
    }
}
Roger VandewaterRoger Vandewater
Hi BalaYesu-
That helped - I forgot to allocate memory. Thanks for your help.
sandeep reddy 37sandeep reddy 37

public class arrylist{
public list<integer>age=new list<integer>{10,20,30,40,50};
public class getvalues{
public integer[] values=new integer[];

values.addall(age);
(or)
fof(intrger i:age){
values.add(i);
}
}
 

}
 

Suraj Tripathi 47Suraj Tripathi 47
Hi Roger Vandewater,
You have to always allocate the memory before using that variable.
In your case, you have not initialized the int_x memory.
Please replace your  'public Integer[] int_x;' from below code-

public Integer[] int_x = new Integer[];

In case you find any other issue please mention. 
If you find your Solution then mark this as the best answer. 

Thanks and Regards
Suraj Tripathi.