I dont understand this 22 substrings


#1
  1. First 3 letters of "Batman"
    "Batman".substring(0,3);
    This is B A T M A N
    0 1 2 3 4 5
    So isnt 0,3 suppose to get BATM

  2. From 4th to 6th letter of "laptop"
    "laptop".substring(3,6);
    This is L A P T O P
    0 1 2 3 4 5
    so isnt 3,6 suppose to be TOP and then one more letter is suppose to be there


#2
B A T M A N
0 1 2 3 4 5

When using substring, it starts with the first number, (in this case, 0) and ENDS one letter/number behind it.

For example:
(in level 22 in Getting Started with Programming)

"wonderful day".substring(3,7)

in this time:

W O N D E R F U L ""    D   A  Y
1 2 3 4 5 6 7 8 9 10    11 12 13

But have you ever pressed "Save & Submit"?
It prints "DERF"!

Hope you get it!:smiley:


#3

I still dont get it ;(((((((

W O N D E R F U L "" D A Y
1 2 3 4 5 6 7 8 9 10 11 12 13

So isnt DERF suppose to be (4,7)

i just cant understand how for the D the substring counts 0123 but then for the F it counts normal 1234567


#4

It does not count like that. Both of them start with 0, except the second number is just a number signaling the one BEFORE it.

Get it?