01:198:213 Lecture Notes - Lecture 5: Parsing

41 views2 pages

Document Summary

Consider public static void main string(args []) {} . This allows the program to work without an instance of the class having to be created. The jvm executes directly on the class instead of having to create an instance of the class. Calling the method directly on the class makes is non-object oriented. An extreme example of static methods is the math class. The reason is because every method is a implementation of a. There is no information being saved or state being maintained. The math class has several mathematical constants that are statically defined in the class. Marked with keyword final i. e. cannot be changed. Can be accessed directly without objects or instances. Consider a class where a limited amount of instances are allowed. Once a certain threshold is reached, throw an error. Create static field count , accessed by all instances of the class. Increment the static field everytime a new instance is created.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents