You need to sign in to do that
Don't have an account?
Roger 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'};
}
}
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'};
}
}
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'};
}
}
That helped - I forgot to allocate memory. Thanks for your help.
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);
}
}
}
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.