For now(2016/9/26), Apex supports do-while, while, and for loops.
do-while:
while:
for(loop in array):
do-while:
Integer count = 1;
do {
System.debug('count' + count);
count++;
} while (count < 3);
while:
Integer count = 1;
while (count < 4) {
System.debug('count' + count);
count++;
}
for(loop in array):
Integer[] is = new Integer[]{1,2,3,4,5};
for (Integer i: is) {
System.debug(i);
}
Queries can also be embedded in the special for syntax.for (Test__c tmp : [SELECT Id FROM Test__c]) {
// ...
}
No comments:
Post a Comment