Can anyone show me an example of what char's do please in java solo learn briefly covers it. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone show me an example of what char's do please in java solo learn briefly covers it.

11th Aug 2017, 10:39 PM
D_Stark
D_Stark - avatar
5 Answers
+ 3
char is for characters, single characters. char myChar = 'p'; Note the simple quotes, simple quotes are for chars while double quotes are for strings, otherwise it throws an error. About what they do, whatever you can think of, for example: a console program that asks to continue (y/n). You could use a string, but you only need one char, so you'd waste memory
11th Aug 2017, 11:07 PM
voidneo
+ 1
You could try to output one after another to make a word, or concatenate them, or I don't know, I don't really use chars
11th Aug 2017, 11:37 PM
voidneo
0
i see thanks, i have seen people use them to make words like hello world how is that done?
11th Aug 2017, 11:34 PM
D_Stark
D_Stark - avatar
0
no probs thanks for your help
11th Aug 2017, 11:37 PM
D_Stark
D_Stark - avatar
0
In addition to noname's answer: You might want to check a String char by char, for instance to check whether each is (or is not) a digit (number), a certain character, ...
12th Aug 2017, 3:10 AM
marit vandijk