+ 1
If I want to print a word on java, I need to put "char" as character in front of the word?
char word= (name)
2 Answers
+ 1
I got it now, thank you @WALL-BUILDER
0
Not exactly, the data type char is for single characters; 8 bits (1 byte). Strings are a class that contains multiple memory adresses, one for each character on the sentence. Therefore, to allocate memory for a word you shall use String type, in order to print a sentence.
String var_name = "Hello World";
Char letter = 'a';
System.out.println(var_name);
System.out.println(letter);
Output:
Hello World
a