+ Start a Discussion
tganikumartganikumar 

Problem with Account object...

Hi,

 

In my environment Account object is not working. Means i written a class like below:

 

public class example{
    public example(){
        Account a = new Account();
        Contact c = new Contact();
    }
}

after clicking save it is giving following error:

 

Error: Compile Error: Constructor not defined: [account].<Constructor>() at line 3 column 21

 

Can you resolve anyone ASAP?

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Do you have a custom class named Account by any chance?

All Answers

AmulAmul

please let me know which Salesforce.com API version are you using?

 

please change your version.

 

Action
Name
Version
Namespace
Type
     
 Salesforce.com API26.0  25.0  24.0  23.0  22.0  21.0  20.0  19.0  18.0  17.0  16.0  15.0  14.0  13.0  12.0  11.1  11.0  10.0  Salesforce.com API
vishal@forcevishal@force

Are you using this class as a Controller for any visualforce page? Check with that and let me know.

bob_buzzardbob_buzzard

Do you have a custom class named Account by any chance?

This was selected as the best answer
tganikumartganikumar

Yes bob, your are right? But, why it is giving an error? I think the my class is overriding the standard class...

can you explain in detail?

tganikumartganikumar

No, but I written the class named as Acount. Then after delete that class it is working fine. But, why it is giving that error? Can you explain in detail?

bob_buzzardbob_buzzard

Your class will override the standard sobject.

 

This is documented at:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_namespace_prefix.htm

 

in the Namespace, Class and Variable Name Precedence section.

 

You can explicitly refer to the sobject via 'System.Account', but I tend to avoid these naming clashes as it makes maintaining the code tricky.