Counting Everything Besides Characters in Java -


i need print every character except letters. (commas, spaces, ect.) , display them. here code far,

public static void main(string[] args)  {     string = "elephant";     string b = "elephant";     string c = "this string.";     string d = "i r gr8, u r gr8";     int ucounter = 0;     int lcounter = 0;     int dcounter = 0;     int ocounter = 0;      (int = 0; < a.length(); i++)     {         if (character.isuppercase(a.charat(i)))             ucounter++;         if (character.islowercase(a.charat(i)))             lcounter++;         if (character.isdigit(a.charat(i)))             dcounter++;     }     system.out.println("string: " + );     system.out.println("\n");     system.out.println("\tlowercase: %d, uppercase: %d, digit: %d, other: " +ucounter);    } 

i having small issue getting them print out numbers after calculating them, separate issue solve on own. have perused forums , cannot seem find how count white space , special characters. allowed use length() , charat() this. character.is?? special characters? or there one?

instead of using if's, use if/else combinations, can make sure you're running one matching case. then, use character.iswhitespace detect white space, , !character.isletter (note !) detect except letters.

it's important if/elses or else last test match digits, commas, whitespace, etc. too.

from class documentation java.lang.character.isletter:

a character considered letter if general category type, provided gettype(codepoint), of following:


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -