Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ages;
names;
accs;
cons;
stds;
Example 3:
Account a1=new Account();
a1.name='Wipro';
Account a2=new Account();
a2.name='TCS';
Account[] accs=new Account[]{a1,a2};
0
1
----------------------------------------------| Account:{Name:wipro} | Account: {Name: Tcs} |
----------------------------------------------================================================================
Reffering to all the elements in the array:
1. We can use for loop
Standard for loop :
for( Integer i=0; i< arrayname.size(); i++){
System.debug(arrayName[i]);
}
Example: Integer[] ages=new Integer[]{10,20,30,40};
0
1
2
3
----------------------------| 10 | 20 | 30 | 40 |
----------------------------Integer size=ages.size(); // size=4
for(Integer i=0;i< ages.size();i++){
System.debug(ages[i]);
}
For Loop : i=0 ; i< 4 ;i ++
System.debug(ages[i]); // Print 10
For Loop : i=1 ; i <4 ; i++
System.debug(ages[i]); // Print 20
For Loop : i=2; i< 4; i++
System.debug(ages[2]) ;// print 30
For Loop : i=3; i< 4 ;i++
System.debug(ages[3]); // print 40
For Loop : i=4; i<4 ;i++ : i<4 condition fail stop
Example 2: