You need to sign in to do that
Don't have an account?
KierenJameson
Why is Object a primitive data type in Apex?
I'm curious if someone can clear up a confusion of mine about Apex primitive data types. I understand in Java that what makes something a primitive data type is a couple of things:
Does Apex have a different definition of what makes something primitive than Java? If so, what is it?
I would be super grateful for someone to help clear this up for me :)
- That it can't be broken down into a smaller unit (e.g., array = non-primitive, long = primitive)
- That primitives are passed by value rather than passed by reference (e.g., boolean = primitive, object reference = non-primitive. )
Does Apex have a different definition of what makes something primitive than Java? If so, what is it?
I would be super grateful for someone to help clear this up for me :)
Thanks for the document link. Ther it's mentioned:
Any data type that is supported in Apex—primitive data types (such as Integer), user-defined custom classes, the sObject generic type, or an sObject specific type (such as Account). All Apex data types inherit from Object.
So object itself is data type of sObject. Like i mentioned above post, you can create instance for an object.
Thanks,
Pratik
All Answers
Please go through the below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_data_types.htm
A primitive, such as an Integer, Double, Long, Date, Datetime, String, ID, or Boolean
An sObject, either as a generic sObject or as a specific sObject, such as an Account, Contact, or MyCustomObject__c
So you can consider SObject as class for which you can create an instance. In database terminology Object/sObject is a Table and the fields on the objects are the Columns of that table.
Please let me know if any further questions.
Thanks,
Pratik
Thanks so much for responding. Sorry I used the wrong url (my bad!). I saw the information in the url you sent, but if I go one step down into the documentation I see that Object is referred to as a primitive data type: http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_primitives.htm
Thoughts?
Kieren
Thanks for the document link. Ther it's mentioned:
Any data type that is supported in Apex—primitive data types (such as Integer), user-defined custom classes, the sObject generic type, or an sObject specific type (such as Account). All Apex data types inherit from Object.
So object itself is data type of sObject. Like i mentioned above post, you can create instance for an object.
Thanks,
Pratik
https://developer.salesforce.com/blogs/developer-relations/2012/05/passing-parameters-by-reference-and-by-value-in-apex.html
and http://www.jitendrazaa.com/blog/java/pass-by-value-and-pass-by-reference/
'...everything in Apex is pass by value but that value is a pointer to the original value thus making everything work like pass by reference. Since all data types follow this rule then the Apex definition of Primitive Data Types seems to be "whatever we want to call a Primitive Data Type." '
Thanks,
Pratik