InterviewSolution
| 1. |
How To Get Characters And Substrings By Index With In A String? |
|
Answer» You can get the character at a particular INDEX WITHIN a string by invoking the charAt() accessor method. String str = "Example String"; Will give char ‘m’. If you WANT to get more than one consecutive character from a string, you can USE the substring method. The substring method has two versions -
You can get the character at a particular index within a string by invoking the charAt() accessor method. String str = "Example String"; Will give char ‘m’. If you want to get more than one consecutive character from a string, you can use the substring method. The substring method has two versions - |
|