Introduction: Using Classes and Objects

We introduce this chapter by providing the prerequisites, learning objectives, and overview.

We'll cover the following



After completing this chapter, you should be able to

  • Describe how a variable of a primitive type differs from a variable of a class type in the way they represent data
  • Use the operator new to create an object
  • Use methods within the class String to manipulate strings
  • Use the class Scanner to extract portions of a string
  • Use the class Date to create and compare two Date objects
  • Use the class BigDecimal to perform decimal arithmetic
  • Use a wrapper class such as Integer to represent primitive data as an object
  • Use the method parseInt in the class Integer to convert a string containing an integer to an int
  • Use constants in the class Integer to discover the minimum and maximum values of an int
  • Use the class Random to generate random numbers
  • Use the class DecimalFormat to format numerical output


Our first chapter introduced the notion of an object, but in this chapter, we will look at the concept in detail. We will introduce several classes that are standard in the Java Class Library and show you how to use them. Our goal is to familiarize you with objects and their behaviors.

Get hands-on with 1200+ tech skills courses.