0

Whats the diffrence between char a = "a"; and String a = "a";?

what can i do with char that i cant do with a String please?

31st Aug 2017, 6:11 PM
D_Stark
D_Stark - avatar
3 ответов
+ 5
char is a primitive data type and you need to use single quotes when initializing it: char letter = 'a'; String is actually a class. char also is a numeric type behind the scenes: letter is also equal to 97, its ascii value (http://www.asciitable.com), and can have mathematical operations performed on it as well as bitwise operations. letter++; letter is now equal to 98 or 'b'
31st Aug 2017, 6:25 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
perfect thanks chaotic i get it.
31st Aug 2017, 8:51 PM
D_Stark
D_Stark - avatar
+ 1
Too vague of a question. Read through java's documentation on the data types. You can manipulate strings in ways that chars cannot. https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
31st Aug 2017, 6:17 PM
vvvvv
vvvvv - avatar