arrays - How do you compare characters in java? -


how compare characters (like strings, such variable.equals(a))? also, doing wrong in line of code:

    char num[] = new char[10];     char num[0] = ' ';     char num[1] = ' ';     char num[2] = ' ';     char num[3] = ' ';     char num[4] = ' ';     char num[5] = ' ';     char num[6] = ' ';     char num[7] = ' ';     char num[8] = ' ';     char num[9] = ' '; 

i'm trying make array of characters, it's giving me error message.

that be:

char[] num = new char[10]; num[0] = ' '; num[1] = ' '; num[2] = ' '; num[3] = ' '; num[4] = ' '; num[5] = ' '; num[6] = ' '; num[7] = ' '; num[8] = ' '; num[9] = ' '; 

or this:

char[] num = new char[] { 'k', 'e', 'v', 'i', 'n' }; 

to compare character can use operators == or < or >

char x = 'x'; char y = 'y';  if( x <> y ) {     //do magic }  if( x == y ) {     //do black magic } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -