Java is a strongly-typed language. The charAt() method returns a char, which you are trying to assign to a String reference variable. You can do one of several things, including changing your variable type to that of char or using the String.valueOf(char c) method to convert the char from charAt() to a string.
Hope this helps....
Steven Bell
Ranch Hand
Joined: Dec 29, 2004
Posts: 1071
posted
0
I'm not sure sure if I answered this with the previous post, but here it goes.
the charAt() method returns a variable of type char which you are trying to assign to a String reference. wrong type.
Also you should not be making so many posts, these questions have been related to the same problem and you should have just asked them in the same thread, much less confusing. Also if you keep creating extra posts for essentially the same/similar topic some people may become annoyed and be less lickely to help you.
Jim Hooper
Greenhorn
Joined: Dec 13, 2004
Posts: 13
posted
0
AH! Many thanks Steve sorted it out a treat... I did try changing the type from String to Char but that seemed to cause an error as well but the String.valueOf() is top draw.
Jim Hooper
Greenhorn
Joined: Dec 13, 2004
Posts: 13
posted
0
Apologies Steven,
Firstly, you did answer my question but then I assigned it to a String, which I now know you can't do.
The reason I reposted rather than replied was because my query had moved on and felty it was a different issue, as proved. I will note my posting habits in future though and apologise.
Forgive an over eager mind?
Dean Jones
Greenhorn
Joined: Jan 04, 2005
Posts: 8
posted
0
char, not Char. Watch the case on the c.
This works just fine.
[ January 05, 2005: Message edited by: Dean Joness ] [ January 05, 2005: Message edited by: Dean Joness ]