Monday, February 9, 2015

Head First Java Chapter 4

    In this chapter I learned more about methods in a class. I learned about using private to hide variables so they don't get values I don't want them to have. If they are private you can still change and view them using getters and setters. I learned that all methods need a return type whether it be void or an actual type. I learned methods can have parameters so you can pass values into it.

Private:





Getters and Setters:







Return Type & Parameters:











Dog Code:

This is the code from chapter 4. I added comments explaining what everything does and had to move the test drive class into a new class file to run it in eclipse. This code uses getters and setters, private varibles, and return types. It makes 2 dogs and makes them bark. The type of bark depends on their size.



No comments:

Post a Comment