String and Sobjects

String :

Strings are set of characters and are enclosed in a single quotes.

They store text values such as a name or an address

Ex:Date d1 = new Date today();

String s = new String valueOf(d1);
The output of above example should be todays date : 2013-06-16;

SObject types :

An Sobject , can be a generic SObject or be a specific Sobjects ,
Such as an Account ,Contact or MyCustom__c

SObjects (Salesforce Objects) are standard or custom objects that stores record data in the Force.com datadase.There is also an Sobject datatype in Apex that is the programatic representation of these Sobjects and their data in code .

Developers refer to SObjects and their fields by their API names.

Ex: Account a = new Account();
MyCustomObject__c co = new MyCustomObject__c();
API name of the custom object.


The following example creates an invoice statement with some initial values for the description__c fileds and assigns it to variable of Invoice-Statement__c,Which is an Sobject type also.

Ex:Invoice_Statement__c inv-new Invoice-Statement__c(Description_c='TestInvoice',Status__c='pending')

SObject variables are initilized to null,but can be assigned a valid object refrence with the new operator.





No comments:

Post a Comment