charAt method
- int index
Returns the character at index
of the String
.
Example
String foo1 = 'esentis';
String char1 = foo1.charAt(0); // returns 'e'
String char2 = foo1.charAt(4); // returns 'n'
String? char3 = foo1.charAt(-20); // returns ''
String? char4 = foo1.charAt(20); // returns ''
Implementation
String charAt(int index) {
if (isBlank) {
return blankIfNull;
}
if (index > length) {
return '';
}
if (index < 0) {
return '';
}
return toArray[index];
}