+ 2

Is it possible to use a return method for a char?

So I have: static char letter(char abr1, char abr2) { return abr1; } My code works, but it can only get abr1, how do I get it to return both? I tried using & and + to "return abr1 + abr2", but it says it cannot convert from int to char.

10th Jul 2016, 11:25 PM
AveryBreeze
4 Answers
+ 2
convert your method into String instead of char since it'll be a string that's returned. Now just create the variable in the method String s = "" + abr1 + abr2; Have to have the double quotations because it adds the characters into them to form the string. Then return s;
11th Jul 2016, 6:12 AM
James
James - avatar
0
I realized something I was doing wrong, I was trying to assign 2 chars into 1 variable, so I need to find a way to convert to 2 chars into a string...
10th Jul 2016, 11:48 PM
AveryBreeze
0
yes
11th Jul 2016, 10:21 AM
Sarabjeet Singh
Sarabjeet Singh - avatar
0
yes you are able to use a return method for a char.
12th Jul 2016, 4:38 PM
robert
robert - avatar