Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

3.6 Wrap-Up

In this chapter, you learned how to create your own classes and methods, create objects of those classes and call methods of those objects to perform useful actions. You declared instance variables of a class to maintain data for each object of the class, and you declared your own methods to operate on that data. You called a method to tell it to perform its task, passed information to a method as arguments whose values are assigned to the method’s parameters and received the value returned by a method. You saw the difference between a local variable of a method and an instance variable of a class, and that only instance variables are initialized automatically. You used a class’s constructor to specify the initial values for an object’s instance variables. You saw how to create UML class diagrams that model visually the methods, attributes and constructors of classes. Finally, you used floating-point numbers (numbers with decimal points). [In Chapter 8, we’ll begin representing monetary amounts precisely with class BigDecimal.] In the next chapter we introduce control statements, which specify the order in which a program’s actions are performed.

  • + Share This
  • 🔖 Save To Your Account