String x= "Computer"; String y= " Application "; System.out.println(x.substring(1,5)); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

String x= "Computer"; String y= " Application "; System.out.println(x.substring(1,5));

give the output of the above line...☝☝

25th Feb 2017, 7:17 PM
Yashasvi Rastogi
Yashasvi Rastogi - avatar
5 Answers
+ 2
It's "ompu" the 5 is not inclusive.
25th Feb 2017, 11:19 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
@George Rabbat Maybe you should first take your own advice! The output is as I said "ompu". I did test it. I also read the documentation. See for yourself. First agument is starting index. Second argument (if present) Is the end index not including. http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
26th Feb 2017, 5:21 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
@ChaoticDawg you right! in C# as i mentioned in Java as your answer! thanks for infos
26th Feb 2017, 5:39 PM
George Rabbat
George Rabbat - avatar
0
omput
25th Feb 2017, 8:51 PM
George Rabbat
George Rabbat - avatar
0
@ChaoticDawg it starts with index (1) then counting 5 characters after it... so it's "omput" test it on code editor or IDE
26th Feb 2017, 3:01 PM
George Rabbat
George Rabbat - avatar