CharAt and Length

CharAt

  • returns the character at the specified index in a string
  • written as CharAt() with the index inside the ()
  • the index starts with a zero (example: with the word Hi, H is 0 and i is 1)
  • includes special characters and spaces
example:
HelloWorld.CharAt(0) is the letter H
HelloWorld.CharAt(1) is the letter e
HelloWorld.CharAt(2) is the letter l
HelloWorld.CharAt(3) is the letter l
HelloWorld.CharAt(4) is the letter o
HelloWorld.CharAt(5) is the letter W


Length
  • shows the length of a string
  • starts at zero
  • includes special characters and spaces
  • written as string.length

No comments:

Post a Comment

Extended Search

Custom Search
Hello World