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

42 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+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents