Basically, you can use the below code snippet to use the contains method like this:
boolean contains = false;
for (char c : charArray) {
if (c == 'q') {
contains = true;
break;
}
}
if (!contains) {
// do something
}
Also, you can use different method like indexOf():
if (new String(charArray).indexOf('q') == -1) {
// do something
}
I hope this will help.
Want to become a Java Expert? Join Java Certification now!!