Question: how to check if a string contains only special characters in java?
Answer: 3 Answers. You can use: String splChrs = "-/@#$%^&_+=()" ; boolean found = inputString. matches("[" + splChrs + "]+");