Lesson 22: Substrings



I have successfully completed this exercise, but I would like a more detailed understanding of how to complete the .substring process. It's a bit confusing. Thanks!


So basically. When you create a string you should look at it like a coordinate plane. if you had the word "Raven" in your string it would be choosing an X value first starting at 0. 0=R, 1=a, 2=v, 3=e, and 4=n. Then once you choose an x value you will have to find a y. The y values start at 1 unlike the x values which starts at 0. Meaning 1=R, 2=a, and so on. Now if I wanted to make a substring of "Rav" with Raven I would start off at R as my x-value. Looking back I see it's the first letter making it 0. I then want the first 3 letters of the word. That means my y value should equal 3. In the end it should look like "Raven".substring(0,3).


And this works every time (because it makes sense)?


Not sure what you mean by that.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.