Java examples for java.lang:char
Determines if the provided character is a special character, that is to say it belongs to the following set: /*!@#$%^&*()\"{}_[]|\\?/<>,.
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { char c = 'a'; System.out.println(isSpecialCharacter(c)); }//w w w . j a v a 2 s.c o m /** * Determines if the provided character is a special character, that is to say it belongs to the following set: * <i>/*!@#$%^&*()\"{}_[]|\\?/<>,. </i> (includes ' ') * @param c a char to check against the set of special characters * @return a boolean, true if the provided char falls into the set of special characters, otherwise false */ public static boolean isSpecialCharacter(char c) { String specialChars = "/*!@#$%^&*()\"{}_[]|\\?/<>,. "; for (int i = 0; i < specialChars.length(); i++) { if (c == specialChars.charAt(i)) { return true; } } return false; } }