int idx1 = mystr.indexOf("@");
how to add one more character with OR operator. like this
mystr.indexOf("@" || "#");
try following code:
int minIndex = Math.min(mystr.indexOf("@") ,mystr.indexOf("#") );
if you don't have one of those char
in your String, this return -1
.
thanks of Adnan that mention on comment
so you need
int idx1 = mystr.indexOf("@");
int idx2 = mystr.indexOf("#");
int minIndex;
if(idx1 >= 0 && idx2 >= 0 )
minIndex = Math.min(mystr.indexOf("@") ,mystr.indexOf("#") );
else if (idx1 >= 0)
minIndex = idx1;
else
minIndex = idx2;