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
Gauri Gaikwad 13Gauri Gaikwad 13 

I am getting error as unexpected token :

//declare a list variable
list<integer> VarEmployeeList= New list<integer> ();
//add values
VarEmployeeList.add(123);
VarEmployeeList.add(1234);    
VarEmployeeList.add(1234);

system.debug(VarEmployeeList);

For(VarOneValue: VarEmployeeList)
{
    system.debug(VarOneValue);
}
 
Best Answer chosen by Gauri Gaikwad 13
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Gauri,

You have error in the for loop. You have to iterate over the list of integers. So i guess the below code should work.
 
list<integer> VarEmployeeList= New list<integer> ();
//add values
VarEmployeeList.add(123);
VarEmployeeList.add(1234);    
VarEmployeeList.add(1234);

system.debug(VarEmployeeList);

For(Integer v: VarEmployeeList)
{
    system.debug(v);
}

If this solution helps, please. mark it as best answer.

Thanks,