0

String s; //enter whatever you want in it for(int i =0; i<s.length(); ++i){ System.out.println(s.substring(0,i)); }

in the above question , what is s.substring(0,i)? what do the two parameters 0 and i do???

8th Mar 2017, 6:45 PM
0000
5 Respostas
+ 12
@Meharban :D Sorry, seriously... missing "" at string init.
8th Mar 2017, 8:08 PM
Tashi N
Tashi N - avatar
+ 11
@Meharban "Meharban Singh"
8th Mar 2017, 8:02 PM
Tashi N
Tashi N - avatar
+ 3
String name='Meharban Singh"; name.substring(4,6); This would return "rb" Hence 4,6 means start from index 4 and end when (6-4=2) characters are selected (space is also a character) Substring is sub-string(subset) of a particular string. In your.case, you are selecting substring from the first letter until i characters are selected. NOTE :- In java index starts from 0.
8th Mar 2017, 6:55 PM
Meharban Singh
Meharban Singh - avatar
+ 1
@Tashi, xD #SelfPromotion 😂
8th Mar 2017, 8:06 PM
Meharban Singh
Meharban Singh - avatar
+ 1
OOPS @Tashi , Thanks ,I changed it.LOL
8th Mar 2017, 8:13 PM
Meharban Singh
Meharban Singh - avatar