Skip to content

Instantly share code, notes, and snippets.

@gitmatheus
Last active March 26, 2021 00:57
Show Gist options
  • Save gitmatheus/5c96af788f3d54b99f6d101f942e777a to your computer and use it in GitHub Desktop.
Save gitmatheus/5c96af788f3d54b99f6d101f942e777a to your computer and use it in GitHub Desktop.
// Creates an instance of the class MyUser
MyUser adminUser = new MyUser();
adminUser.username = 'admin';
adminUser.password = 'admin';
// non-static method, it needs to be called from each instance
adminUser.validateCredentials();
// Creates another instance of the class MyUser
MyUser regularUser = new MyUser();
regularUser.username = 'myusername';
regularUser.password = 'mypassword';
// non-static method, it needs to be called from each instance
regularUser.validateCredentials();
// calling the method using values that do not belong to an instance:
// You do not need a new instance of the class to use its static methods
Boolean validated = MySecurityClass.validateCredentials('test', 'test');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment