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

Keywords and APEX

Wired behavior of APEX class.

Can anybody explain why I am able to save class with some object name as class name while not with others?
For Ex: In below code I am able to save public class User, public class account but not public class case or public class customObject__c.
APEX Class:

public class user {
// Custom Object
public class Tester_s_Obj2__c{

Public class Account{
// Another Standard Object
public class case{


Hi Ritik,

As Salesforce support MVC architecture and when ever either a custom object or most of the standrad object they have created already have auto associated with a class with that object name .So you should not create a class with same as object Name .

PLease check below link and let me know any issue
sandeep sankhlasandeep sankhla
Hi Ritik,

It is not like few objects are available or few are not..

Apex have many reserve keyword and if you use them as a name then that will throw an error..check below link to see all reserve keyword for Apex

Here in this link Account is not a reserve keyword so you are able to save you rvariable name with account..but if you will check then Case is reserved from apex and this is why you are not able to use that..

it is not at all depoendet on object or somelevel..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Salesforce Certified Developer