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

  • 1
    You are having a method inside another method >??? createContacts(Integer size, Id accId, Boolean doInsert)inside ContactServicesDataUtility() if you wanted to have ContactServicesDataUtility as a class you need to use private class ContactServicesDataUtility{ } and not private ContactServicesDataUtility(){}
    – Rao
    Mar 13, 2014 at 17:24
  • @rao your comment should be posted an answer.
    – Mark Pond
    Mar 13, 2014 at 17:27
  • @MarkPond The intend of the user was not clear so made it a comment. I was not sure if it was a copy paste error/ programming error so had it as a comment
    – Rao
    Mar 13, 2014 at 17:28
  • Yes thats exactly what im trying to do make a private class, sorry if i was unclear i will edit my question
    – user7167
    Mar 13, 2014 at 17:31

1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .