AP Computer Science in Java
  • Introduction
  • Introduction to Programming in Java with Karel the Dog
    • Introduction to Programming with Karel
    • More Basic Karel
    • Java Programs and the Run Method
    • Karel Can't Turn Right
    • Methods in Karel
    • Top Down Design and Decomposition in Karel
    • Commenting Your Code
    • SuperKarel
    • For Loops
    • While Loops in Karel
    • If Statements
    • If/Else Statements
    • Control Structures Example
    • How To Indent Your Code
  • Basic Java
    • Printing in Java
    • Variables and Types
    • User Input
    • Arithmetic Expressions
    • Casting
    • Booleans
    • Logical Operators
    • Comparison Operators
    • For Loops
    • While Loops
    • If Statements
    • Loop-and-a-Half
    • Short-Circuit Evaluation
    • De Morgan's Laws
    • Strings
  • Methods
    • Java Methods
    • Methods and Parameters
    • Methods and Return Values
    • Javadoc and More Methods
    • Strings Methods
    • Strings and Characters
    • Exceptions
    • String Processing
  • Classes and Object-Oriented Programming
    • Introduction To Classes and Objects
    • Classes vs. Objects
    • Using a Class as a Client
    • Writing Classes
    • Writing Classes and Instance Methods
    • Getter and Setter Methods
    • Class Methods and Class Variables
    • Method Overloading
    • Local Variables and Scope
    • Key Terms for Classes
    • Objects vs Primitives
    • Inheritance
    • Class Design and Abstract Classes
    • Polymorphism
    • Interfaces
  • Data Structures
    • What Are Data Structures?
    • Introduction to Arrays
    • Using Arrays
    • ArrayList Methods
    • Arrays vs ArrayLists
    • 2D Arrays (Matrices or Grids)
    • Hashmaps
  • Algorithms and Recursion
    • What is an Algorithm?
    • Pseudocode
    • Linear Search
    • Binary Search
    • Selection Sort
    • Insertion Sort
    • Advanced: Recursion
    • Mergesort
Powered by GitBook
On this page

Was this helpful?

  1. Classes and Object-Oriented Programming

Using a Class as a Client

PreviousClasses vs. ObjectsNextWriting Classes

Last updated 5 years ago

Was this helpful?

In Java, you can think of everything as a class. If you want to write a program to act as a grade book, GradeBook is a class. The same can be thought of with any program you code in Java.

Since you can think of everything as a class in Java, you can bundle these classes and their functionality. You can even use classes that are written by other people without knowing exactly how they work.

Whenever you use a class, it is class a client of the class.

Reading Documentation

Documentation is a great resource to use to see how a class works. As long as you can read the documentation, you don't need to know how the class works.

Here is an example of the documentation for the String Class: ()

The documentation for a class tells us how to use the class constructor, and various methods that the class provides.

Here is another example of documentation: ()

This documentation is for the Rectangle Class that you may have worked with in previous exercises.

http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
https://codehs.com/editor/slides/75977/97708/277/53
Rect Class
String Class 1
String Class 2