0
Example of char in java
hey, can anyone give me a simple java char example please maby a bit of explaining how it works. thanks
4 Respuestas
+ 1
char c='a';
In this case variable c is a variable of type char (character)
It represents a SNGLE character and it requires single quote marks (instead of doubles quote marks used in string type). It takes 1 byte of memory...
+ 1
char ch = 'a';
char is the data type
'a' is the value, use single qoute marks (unlike in atrings which use double qoute marks)
this is very basic explaination but i hope it's enough.
+ 1
syntax :
char var_name = 'x'; /* any character but must be assigned in single quotes*/
example :
char ex_char = 'b';
0
thanks, but whats its purpose as u could do this with a switch string case?