UOB - String Methods (Lesson)

APCompSci_LessonTopBanner.png

String Methods

Introduction

When given a complex programming task, Application Program Interfaces (APIs) and libraries are used to make things simpler. Instead of having to recreate everything from scratch, libraries of already created code can be used. This frees the programmer up to utilize existing code while writing new code. For APIs to be beneficial, documentation to understand behaviors of an object of a class are essential. If you wanted to create an Address Book class and a Person class already exists containing each person object’s address that would be very helpful to use. Hopefully, the person object methods are documented so that we can see how to use them without having to read all the code.

Classes in the APIs and libraries are grouped into packages. The String class is part of the java.lang package. Oftentimes, an import statement must be included at the start of our java code in order to access a package, however, classes in the java.lang package are available by default. The String class contains numerous methods. We will focus on a few specific methods in this course.

String Methods

 A method is a storage location for program statements. It represents what an object can do or have done to it. When a method is called it performs a task. The String class has many methods. The String class methods that will be tested on the AP Exam can be found on the Java Quick Reference located in Resources under the book icon in the upper right corner. This is a document which will be provided during the AP Exam. You should become familiar with it now.

Click below to learn more about String methods in the learning activity.

 

Book Icon Click on "Runestone Academy" below to open the required reading that is listed.

Runestone Academy: AP CSA – Java Review Links to an external site.

READ: 4.3 – String Methods on the Exam

Click on "Introduction to Computer Science Using Java" below to open the required reading that is listed.

Book Icon Introduction to Computer Science Using Java Links to an external site.

READ: Chapter 45 - More about Strings

Complete the quiz for practice.

Self-Check Practice

Practice Icon Practice-It! Self-Check

More String Methods

Click below to learn about more string methods.

 

APCompSci_LessonBottomBanner.pngIMAGES CREATED BY GAVS