We can go with String method and matching regex pattern to find the count of special char's in a string Input. Example: public class Testing { public static void main(String[] args) { String inputStr = "1234 Special Char count test example@$$%^^$&**() using String method @@#@"; System.out.println(inputStr.replaceAll("[0-9A-Za-z\\s]", "")); System.out.println("Count:"+(inputStr.replaceAll("[0-9A-Za-z\\s]", "").length())); } } Output: @$$%^^$&**()@@#@ Count:16