Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java indexOf returns false for unfound string?

Tags:

java

I need to know whether in Java does the indexOf() method return false or void for an unfound string? or does it return an index int of 0?

like image 323
Supernovah Avatar asked Mar 30 '09 11:03

Supernovah


2 Answers

It'll return -1 (hint: try it)

As in the JavaDoc

like image 198
Brian Agnew Avatar answered Oct 10 '22 04:10

Brian Agnew


The Java API docs contain this answer. the indexOf methods on a String return -1 if the character is not found.

like image 28
Thomas Owens Avatar answered Oct 10 '22 06:10

Thomas Owens