Find your content:

Search form

You are here

How to write a private inner class

 
Share

I am trying to create a private DataUtility class within my test class. I need it to create a list of contacts within this private class. I am aware that I can create another class within my org but I was told not to do so here is what my private class currently looks like

private ContactServicesDataUtility(){
        private List<Contact> createContacts(Integer size, Id accId, Boolean doInsert){
            for (Integer i = 0; i < size; i++){
                List<Contact> contacts = new Contact();
                newContact.AccountId = accId;
                newContact.FirstName = null + i;
                newContact.LastName = 'Test_' + i;
            }
        }

    }

I recieve the error unexpected token: 'List', I know that I cannot use static, what is the proper syntax for this?

Thank you in advance


Attribution to: user7167

Possible Suggestion/Solution #1

Instead of private ContactServicesDataUtility(), private class ContactServicesDataUtility{} or if you are trying to having a constructor take out the createContacts from that.


Attribution to: highfive
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30118

My Block Status

My Block Content