Tuesday, January 28, 2014

What is difference between public and global class in Apex

What is difference between public and global class in Apex

Public class can be accessed within application or namespace. This is not exactly like public modifier in Java.
Global class visible everywhere , any application or namespace. WebService must be declared as Global and which can be accessed inside Javascript also. It is like public modifier in Java.
global class MySchedulableClass implements Schedulable {} - schedular class
global class UpdateController {
webService static string updateEnable(List<Id> accId){}
} - javascript remoting

global class MyWebService {
    webService static Id makeContact(String lastName, Account a) {
        Contact c = new Contact(lastName = 'Weissman', AccountId = a.Id);
        insert c;
        return c.id;
    }
} 

No comments:

Post a Comment