[Logo]
Forums Register Login
String method....
public int indexOf(int ch, int fromIndex)
*if the fromIndex is greater than the length of the string wats the
effect....
*if the fromIndex is equal to the length of the string wats the
effect....
*if the fromIndex is negative wats the effect....
There is no restriction on the value of fromIndex. If it is negative, it has the same effect as if it were zero: this entire string may be searched. If it is greater than the length of this string, it has the same effect as if it were equal to the length of this string: -1 is returned.
hope this sample code will help your understanding!!!




And the output is as follows:

Index equals String Length: -1
Index greater than String Length: -1
Index is negative: 5



Thanks
Balaji.S
Can u explain it more....

This thread has been viewed 487 times.

All times above are in ranch (not your local) time.
The current ranch time is
Nov 12, 2018 11:09:39.