Results 1 to 2 of 2
- 12-13-2007, 08:48 PM #1
Member
- Join Date
- Dec 2007
- Location
- Philly
- Posts
- 3
- Rep Power
- 0
Cannot convert from char to String error
Still working on my hangman program from yesterday (Thanks Shoeninja for help!)
I re-did a bunch of it to include global variables and such
here is the method I am still having problems with:
BuildWord is a global string variable with the value " " (8 spaces). the loop compares your 1-char guess with all 8 characters of a randomly chosen 8-letter word. What buildword does is keep track of the word you've guessed so far. So say the word is aardvark, and you guess "a" I want buildword set to "aa a ", using cnt from the for loop to replace the appropriate spaces.
"String tempword = BuildWord.charAt(cnt)" is where I am getting the cannot convert from char to string error.
thanks,Java Code:public static void compare () {//BEGIN COMPARISON BuildWord=" "; for (int cnt=0;cnt <=7; cnt++) {//begin for String templetter = guessedletter; String tempword = BuildWord.charAt(cnt) //compares your one character guess to every character of the wordchosen if (guessedletter.charAt(0) == wordchosen.charAt(cnt)) { tempword = templetter; } else wrongt++; }//end for
-Sondra
- 12-13-2007, 09:28 PM #2
Similar Threads
-
How to convert a string into a BigInteger
By valery in forum New To JavaReplies: 4Last Post: 09-13-2011, 01:32 PM -
How can i insert a char into a string
By Jamie in forum New To JavaReplies: 8Last Post: 02-17-2011, 08:59 PM -
Char to String in java
By trill in forum New To JavaReplies: 1Last Post: 08-01-2007, 01:42 PM -
Help with, String, Char
By lenny in forum New To JavaReplies: 1Last Post: 07-25-2007, 02:58 PM -
Error: convert from String to long
By bbq in forum New To JavaReplies: 1Last Post: 06-29-2007, 07:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks