Strings

Cards (11)

  • Strings are written inside double quotation marks but sometimes single quotes are used
  • Strings can be joined together to form new strings - this is called concatenation - It's often done using the + operator
  • Characters in a string are usually numbered starting at 0
  • What is the role of the x.upper string manipulation function?
    It changes all characters in string x to upper case
  • What is the role of the x.lower string manipulation function?
    It changes all characters in string x to lower case
  • What is the role of the x.length string manipulation function?
    It returns the number of characters in string x
  • What is the role of the x.left(i) string manipulation function?
    It exctracts the first i characters from string x
  • What is the role of the x.right(i) string manipulation function?
    It extracts the last i characters from string x
  • What is the role of the x.substring(a, b) string manipulation function?
    It extracts a string starting at position a with length b from string x
  • upper, lower, length, left, right and substring are special functions called methods - they act on a particular object (in this case strings) and are called using the object's name followed by a dot "." and the method's name
  • substring, left, and right are examples of 'slicing' - where part of a string is extracted and returned as a new string