Home > Articles > Programming > Java

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

3.6 Wrap-Up

In this chapter, you learned how to create your own Java 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 methods and passed information to them as arguments whose values are assigned to the method’s parameters. You learned 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 also learned how to use 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 the methods, attributes and constructors of classes. Finally, you learned about floating-point numbers (numbers with decimal points)—how to store them with variables of primitive type double, how to input them with a Scanner object and how to format them with printf and format specifier %f for display purposes. [In Chapter 8, we’ll begin representing monetary amounts precisely with class BigDecimal.] In the next chapter we discuss control statements, which specify the order in which a program’s actions are performed.

  • + Share This
  • 🔖 Save To Your Account