tags:

views:

128

answers:

4

why doesnt any of these work:

 char word = "sds";
 char word = 'sds';
 myDog.bark("voff");
 myDog.bark('voff');

in the object to myDog i have typed:

 void bark(char word) {
      System.out.println(word);
 }
+10  A: 

Because a char is just a single character. You want to use the String type instead.

void bark(String word) {
   System.out.println(word);
}
Mark Byers
+3  A: 

The char data type can only contain one character. For multiple characters, you should use the String data type.

indyK1ng
+4  A: 

You want to use "String" not "char". char is only for 1 character, "String" is for multiple characters.

With "String" type you use double-quotes, with "char" you use single quotes:

char c = 'a';
String s = "hello";
Noon Silk
+2  A: 

char is one character, String is a sequence of chars. You are looking for a String

Aly