How can you get the last character of a string `s`?

  1. s.charAt(s.length())
  2. s.charAt(s.length - 1)
  3. s.charAt(s.length() - 1)
  4. s.last()
Correct answer s.charAt(s.length() - 1)

Explanation

s.charAt(s.length() - 1) returns the last character of a string.

Update: Admin added a tag on this question

Topics

By Admin · · 21 views