-1

How add three arrays in Apex programming ?

String[] s1 = new String[]{"a", "b", "c"};
String[] s2 = new String[]{"d", "e", "f"};
String[] s3 = new String[]{"g", "h", "i"};

I need to create the single array in apex?

  • Downvote from me for lack of research. This is a really basic question that can be answered by looking through documentation. (Specifically, the documentation on the List class). Googling for "apex <insert class name here>" usually works pretty well. – Derek F Apr 24 '17 at 12:35
3

Use public Void addAll(List fromList) method to merge all elements from one list into another. Refer documentation for more details.

Below code merges list s2 and s3 into s1

String[] s1 = new String[]{"a", "b", "c"};
String[] s2 = new String[]{"d", "e", "f"};
String[] s3 = new String[]{"g", "h", "i"};
s1.addAll(s2);
s1.addAll(s3);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.