Adding a Method to the Box Class Java Help

Adding a Method to the Box Class

Although it is perfectly fine to create a class that contains only data, it rarely happens, Most of the time you will use methods to access the instance variables defined by the . . class. In fact, methods dcfir e the interface to most classes ..This allows the class implementor to hide the specific layout of intemaldata structuresbehind cleaner· method abstractions, In addition to defining methods that provide access to data, you can also define methods that are used internally by the class itself. " Let's begin by adding a method to the Box class. It may have occurred to you while looking-at the preceding programs that the computation of a box's volume wns something that was best handled by the Box class rather than .the BoxDem'o class, After

Posted on September 17, 2014 in Introducing Classes

Share the Story

About the Author

Back to Top
Share This