COMPSCI 61B Lecture Notes - Lecture 4: Instance Variable

86 views5 pages

Document Summary

While functional, naked linked lists like intlist are hard to use. Instead of an intlist class, we will have an intnode class. Intnode is now dumb, and has no methods at this time. Introduce sllist, which is a list of integers, which hides the terrible truth of the nakedness within. Sllist is easier to instantiate (no need to specify null) While functional, intlist class is harder to use. Users of intlist are need to know java references well, and be able to think recursively. Sllist class acts as a middle man between user and raw data structure. Users of our class might be tempted to try to manipulate our secret intnode directly in uncouth ways. We can prevent programmers from making such mistakes with the private keyword. Use the private keyword to prevent code in other classes from using members (or constructors) of a class. Hide implementation details from users of your class.

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