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

4th Jul 2017, 2:35 PM
D_Stark
D_Stark - avatar
4 ответов
+ 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...
4th Jul 2017, 2:41 PM
2_3rr0r5
2_3rr0r5 - avatar
+ 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.
4th Jul 2017, 2:42 PM
erez
erez - avatar
+ 1
syntax : char var_name = 'x'; /* any character but must be assigned in single quotes*/ example : char ex_char = 'b';
4th Jul 2017, 2:49 PM
Liyakat Shaikh
Liyakat Shaikh - avatar
0
thanks, but whats its purpose as u could do this with a switch string case?
4th Jul 2017, 2:50 PM
D_Stark
D_Stark - avatar