-2

When I use:

char[] abcCyr = {'a','б','в','г','д','ё','ж','з','и','к','л','м','н','п','р','с','т','у','ў','ф','х','ц','ш','щ','ы','ю','я'};

Nothing is wrong, but when I try to change type of array to String, eclipse forbid me to do this. What is wrong?

Rudziankoŭ
  • 10,681
  • 20
  • 92
  • 192
  • 6
    Char literals use single quotes. String literals use double. – PakkuDon Feb 02 '14 at 10:15
  • 2
    How about showing us the code that doesn't compile, with the error message you get, rather than showing us the code that doesn't have any problem? You want us to guess what the problem is? – JB Nizet Feb 02 '14 at 10:16
  • Here usefull answers http://stackoverflow.com/questions/439485/is-there-a-difference-between-single-and-double-quotes-in-java – StarsSky Feb 02 '14 at 10:17

2 Answers2

8

'a' is char

"a" is String

In order to use String:

String[] abcCyr = {"a", "б","в"}
BobTheBuilder
  • 18,858
  • 6
  • 40
  • 61
5
char[] abcCyr = {'a','б','в'};
String[] abc = {"abc","def","ghi"};

char is a primitive type. String is a class.

Maroun
  • 94,125
  • 30
  • 188
  • 241
Kick
  • 4,823
  • 3
  • 22
  • 29