function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shoesmanshoesman 

how to write "for loop" in apex controller ??

hi

 

Could some advice me how to write "for loop" in apex code, 

I know "for loop" is very basic thing but I don know I cant make it.....

 

this is copy of my controller

 

-----------------------------------------------------------

public double getRandomNumber() {        
     for (double i = 0, j = 0; i < 10; i++) {
     double ran =Math.round(Math.random()*100);
   
     return ran(i+1);   
     }

-----------------------------------------------------------

 

I know I can do it one by one, but using "for loop" should be better for my study

 

please kindly show me how to make it ?:smileysad::smileysurprised::smileysad:

 

thanks

 

David VPDavid VP

The docs have a specific section on the different types of loops you can construct :

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_loops.htm

 

 

shoesmanshoesman

thanks david !!

 

I didnt know there is such useful docs  :smileytongue: