indexOf function is used to find the character in a String. It will return '-1' on failure i.e. no character found in a String else it will return the position of the character.
Example
@ Special Character Found in a postion 7
Example
public class example
{
public static void main(String[] args)
{
String email="example@gmail.com";
int pos=email.indexOf('@');
if(pos!=-1)
{
System.out.println("@ Special Character Found in a postion "+pos);
}
else
{
System.out.println("@ Special Character Not Found");
}
}
}
Output@ Special Character Found in a postion 7