+ 3
How the answer is 4?
String greeting="Sololearn"; System.out.print(greeting.indexOf("Solo")); System.out.print(greeting.indexOf("Learn"));
3 odpowiedzi
+ 4
when the character is not found in the given string its returns -1.
here 'L' is not there in sololearn so it returns -1.
is output : 0-1
+ 3
Answer is "04"
Method indexOf(String str) returns the index within this string of the first occurrence of the specified substring.
I think there is a mistake in the task, author meant
String greeting =" SoloLearn"
+ 2
the answer is not 4, the answer is "0-1"