我知道,我可以返回一个字符串的indexOf()函数的特定字符的索引。 但是,我怎么能与特定的索引返回字符?
解决方案 字符串s =你好;
焦炭C = S [1];
//现在ç=='E'
另请参见子串
,返回多个字符。
I know that i could return the index of a particular character of a string with indexof() function. But how i could return the character with the particular index?
解决方案string s = "hello";
char c = s[1];
// now c == 'e'
See also Substring
, to return more than one character.