+ Start a Discussion
Subin009Subin009 

for loop trivial error Expecting '}' but was: 'for'

Hi Lately I am getting Expecting '}' but was: 'for' while saving for loop in apex.

Even a simple for loop counter is not working..Experiencing this today.

Please asssit.
Thanks
Subin Babu
Please see the code

public with sharing class sharedLocStockAdjust {
    for(Schema.Location temp : [select Id,Name from Location where LocationType='Van'])
    {
    }
}
ravi soniravi soni
hy subin,
try following code.
public with sharing class sharedLocStockAdjust {
    public static void localMethod(){
    for(Schema.Location temp : [select Id,Name from Location where LocationType='Van']){
        system.debug('temp : ' + temp);
    }
}
}
let me know if it helps you and don't forget to mark it as best answer.
Thank you
 
Subin009Subin009
Thank you ..That fixed it..forgot to add the function :) Appreciate your help.