Arrays in Salesforce Apex
Array:
Array is a collection of similar elements, where the memory allocated sequently.
Data type [] array name = New data type (size);
// this is called dynamic declaration
Data type [] array name = New data type [] {value; value 2};
// static declaration
Integer [] marks = new integer [] {10,20,30};
Account a1 = new account (name=’same’);
Account a2 = new account (name=’ram’);
Account [] acc = new account [] {a1, a2};
String [] s1 = new string [] {‘ram’, ‘Sam’, ‘ram’};
String [] s1 new string [4];
S1[0] = ‘Kumar’;
S1 [1] = ‘Ravi’;
No comments:
Post a Comment