You can check string is alphanumeric in Java using matches() technique for Matcher class. The Matcher class is given by java.util.regex bundle.
Beneath I have shared a basic Java program in which I have taken a string and I am checking it using matches() strategy.
Program
java.util.regex.*;
class AlphanumericExample
{
public static void main(String...s)
{
String s1="adA12", s2="jh@l";
System.out.println(s1.matches("[a-zA-Z0-9]+"));
System.out.println(s2.matches("[a-zA-Z0-9]+"));
}
}
Output