Using Apache Commons Lang:

!StringUtils.isAlphanumeric(String)

Alternativly iterate over String's characters and check with:

!Character.isLetterOrDigit(char)

You've still one problem left: Your example string "abcdefà" is alphanumeric, since à is a letter. But I think you want it to be considered non-alphanumeric, right?!

So you may want to use regular expression instead:

String s = "abcdefà";
Pattern p = Pattern.compile("[^a-zA-Z0-9]");
boolean hasSpecialChar = p.matcher(s).find();
Answer from Fabian Barney on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java string › check if a string is strictly alphanumeric with java
Check if a String Is Strictly Alphanumeric With Java | Baeldung
October 9, 2023 - We can implement isAlphanumeric(int) in several ways, but overall, we must match the character code in the ASCII table.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Character.html
Character (Java Platform SE 8 )
5 days ago - Consequently, the behavior of fields and methods of class Character may vary across implementations of the Java SE 8 Platform when processing the aforementioned code points ( outside of version 6.2 ), except for the following methods that define Java identifiers: isJavaIdentifierStart(int), isJavaIdentifierStart(char), isJavaIdentifierPart(int), and isJavaIdentifierPart(char).
🌐
Educative
educative.io › answers › what-is-stringutilsisalphanumeric-in-java
What is StringUtils.isAlphanumeric in Java?
isAlphanumeric() is a static method of the StringUtils class that is used to check if the given string only contains Unicode letters or digits.
🌐
Mkyong
mkyong.com › home › regular expressions › java regex check alphanumeric string
Java regex check alphanumeric string - Mkyong.com
November 8, 2020 - Below is a Java regex to match alphanumeric characters. ... package com.mkyong.regex.string; public class StringUtils { private static final String ALPHANUMERIC_PATTERN = "^[a-zA-Z0-9]+$"; public static boolean isAlphanumeric(final String input) { return input.matches(ALPHANUMERIC_PATTERN); } }
🌐
IncludeHelp
includehelp.com › java-programs › check-a-given-character-is-alphanumeric-or-not-without-using-a-built-in-method.aspx
Java program to check a given character is alphanumeric or not without using a built-in method
February 24, 2022 - // Java program to check a given character is // alphanumeric or not without using // the built-in method import java.util.Scanner; public class Main { static boolean isAlphaNumeric(char ch) { if ((ch >= '0' & ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) return true; return false; } public static void main(String[] args) { Scanner X = new Scanner(System.in); char ch = 0; System.out.printf("Enter character: "); ch = X.next().charAt(0); if (isAlphaNumeric(ch)) System.out.printf("Given character is an alphanumeric character\n"); else System.out.printf("Given character is not an alphanumeric character\n"); } } RUN 1: Enter character: K Given character is an alphanumeric character RUN 2: Enter character: 8 Given character is an alphanumeric character RUN 3: Enter character: % Given character is not an alphanumeric character ·
Find elsewhere
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
String Contains Non-Alphanumeric Characters in Java - Java Code Geeks
July 14, 2023 - A more concise and efficient way to solve this problem is by using regular expressions. We can define a regular expression pattern that matches any non-alphanumeric character and then use the Pattern and Matcher classes from the java.util.regex package to find matches in the input string.
🌐
Alvin Alexander
alvinalexander.com › blog › post › java › remove-non-alphanumeric-characters-java-string
Java alphanumeric patterns: How to remove non-alphanumeric characters from a Java String | alvinalexander.com
April 18, 2019 - Here's a sample Java program that shows how you can remove all characters from a Java String other than the alphanumeric characters (i.e., a-Z and 0-9).
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.6 documentation
In particular, the output of float.hex() is usable as a hexadecimal floating-point literal in C or Java code, and hexadecimal strings produced by C’s %a format character or Java’s Double.toHexString are accepted by float.fromhex().
🌐
LinkedIn
linkedin.com › pulse › different-approaches-print-number-from-alphanumeric-strings-varhekar
Different Approaches to print the number from Alphanumeric Strings using Java
June 8, 2018 - package Others; import java.util.Scanner; // Approach -1 Java Program to print numbers only from incoming string // using String Builder and Character syntax public class printNumFromString { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.println("Enther the string:"); String sampleString = sc.nextLine(); System.out.println("Sample String is " +sampleString); sc.close(); // Invoking String builder StringBuilder myNumbers = new StringBuilder(); for (int i = 0; i < sampleString.length(); i++) { //Using java native chara
🌐
Codecademy
codecademy.com › docs › python › strings › .isalnum()
Python | Strings | .isalnum() | Codecademy
July 15, 2025 - Returns True if all characters in a string are alphanumeric (letters and numbers).
🌐
Oracle
forums.oracle.com › ords › apexds › post › check-if-a-string-contains-numeric-and-alphanumeric-charact-8516
Check if a string contains numeric and alphanumeric character - Oracle Forums
April 10, 2012 - I have a string input from user.I have to check if it contains atleast one numeric ,one alphanumeic character ,atleast one lower case letter. How do I do this. Will some regular expression be useful.P...
🌐
How to do in Java
howtodoinjava.com › home › java regular expressions › regex for alphanumeric characters (+ example)
Regex for Alphanumeric Characters (+ Example)
June 29, 2024 - Use regex “\\p{Alnum}+” to match any alphanumeric character (letters and digits) recognized in any Java Locale.
🌐
W3Schools
w3schools.com › python › ref_string_isalnum.asp
Python String isalnum() Method
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › how to remove all non-alphanumeric characters from a string in java?
Remove Non-Alphanumeric Characters from a String in Java
December 19, 2024 - How to Remove Non-alphanumeric Characters in Java: Method 1: Using ASCII values Method 2: Using String.replace() Method 3: Using String.replaceAll() and Regular Expression
🌐
The Crazy Programmer
thecrazyprogrammer.com › home › how to check string is alphanumeric in java
How to Check String is Alphanumeric in Java
July 22, 2015 - 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]+")); } }