Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Lesson 2.15 Strings

Description

A String is a sequence of characters. We use Strings to represent full words and sentences. For example, the famous “Hello World” is a String. Some more examples of Strings:
“I am a String. A sequence of characters strung together to form words and/or sentences.”
“CodeHS is the best coding website ever! Everyone loves CodeHS!”
“She sells sea shells by the sea shore.”
“Strings!”
“abcdefghijklmnopqrstuvwxyz”
A String is not a primitive type like int, char, boolean, and double are. Primitive types always start with lowercase letters, but a String starts with a capital letter. This makes it an object.


Objective

Students will be able to…

  • Explain that a String is a sequence of characters
  • Explain the difference between a String and a primitive type
  • Create String variables and initialize them to hold String values
  • Concatenate String values together
  • Compare Strings correctly using .equals instead of ==