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
Srinivas NimmagaddaSrinivas Nimmagadda 

Missing '<EOF>' at 'List'

1. Creating a wrapper class Employee with last name, first name, phone, email.
2. SOQL query on Contact to fetch lastName, firstName, Phone, email.
3. Taking one by one contact and creating employee based on the data in the contact
4. Adding to a set
 
public class Employee {
        public String lastName;
        public String firstName;
        public String phone;
        public String email;
}
        List<Contact> contacts = [select FirstName,LastName,Phone,Email from Contact];
<!-- Here it is showing me the ERROR 
       ERROR: Missing '<EOF>' at 'List'        
-->
        Set<Employee> employees =new Set<Employee>();
        
        for(Contact c:contacts){
            
            Employee e =new Employee();
            e.LastName=c.LastName;
            e.firstName=c.firstName;
            e.Phone=c.Phone;
            e.Email =c.Email;
            employees.add(e);
        }

Can someone tell me what is the issue
Raju yadavRaju yadav
Hi Srinivas Nimmagadda,
Please use a method for calculation as give below this might help you
 
public class wrapTest{

   public wrapTest(){
   }
   
   List<Contact> contacts = [select FirstName,LastName,Phone,Email from Contact];
   Set<Employee> employees =new Set<Employee>();
   
   public void myMethod(){
       for(Contact c : contacts ){
            Employee e =new Employee();
            e.LastName=c.LastName;
            e.firstName=c.firstName;
            e.Phone=c.Phone;
            e.Email =c.Email;
            employees.add(e);
        
       }
   }
   
   
   public class Employee {
        public String lastName;
        public String firstName;
        public String phone;
        public String email;
   }
        
}

Thanks
Bvenkat Jeewesh(Dev)Bvenkat Jeewesh(Dev)
Hi Srinivas Nimmagadda,
Please implement this Code.
public class Employee_Class
        {
            
             List<Contact> contacts = [select FirstName,LastName,Phone,Email from Contact];
             Set<Employee> employees =new Set<Employee>();
             
              for(Contact c:contacts)
              {            
                WarppEmpClass wrapobj =new WarppEmpClass();
                wrapobj.LastName=c.LastName;
                wrapobj.firstName=c.firstName;
                wrapobj.Phone=c.Phone;
                wrapobj.Email =c.Email;
                employees.add(wrapobj);
              }
        system.debug('>>>>employees>>>>'+employees);
             
            
                public class WarppEmpClass
                {
                        public String lastName;
                        public String firstName;
                        public String phone;
                        public String email;
                }
            
            
            
            
        }