The shortest way to check for the availability of a character in a String without having to manually iterate through it is done via a pre-built function inside JAVA known as indexOf().
If we have to check for the availability of a character 'a' inside a String y="bac", we use:
int v=y.indexOf('a');
The function returns the index of the character in the String on its availability and returns '-1' otherwise. Here, the value of v will be '1' since the character 'a' is on index number 1.