Last active
March 26, 2021 00:57
-
-
Save gitmatheus/5c96af788f3d54b99f6d101f942e777a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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