+ 1
What is the difference between string and char?
char and string are two datatypes..but we used both alphabets carrier! tell me the full description!
9 Answers
+ 3
char is just one character
eg: "h"
+ 3
Ziyaan, you wrote:
>> char is just one character
eg: "h" <<
which is half true.
Char is one character, it is true, but you have to write it like this: 'h'.
When you write it like this: "h" it means String with just one character in it.
Strings are objects, and char is primitive type.
You can type System.out.print("h".length()) /try this in Code Playground/
and as a result you'll get the length of object "h".
+ 2
char is only one single character & stores memory a little bit lower than string.
eg: char "a"
string "apple"
they both need " " or ' ' (double quote).
cmiiwđ
+ 1
char is single character written in single quote but in case of string it is group of character it is written in double quote
+ 1
char datatype is included in between single quotes ' ' whereas to declare a string u need to put it in double qoutes "abhinav"
0
thank you ziyaan
0
char means just 1 character like'g'....n string means group of character in "-" this like "char"
0
in string we maintaining the sequence of characters
0
char contains only single inverted commas but in string we have to put double qoutes ! @nadhifa_sofia đ