How to assign a value of a char within a char array (Java) [duplicate]

This question already has an answer here:

Difference between “char” and “String” in Java

14 answers

For my compsci class, we're doing the Array unit and are coding a reverse-hangman type program. I created a method to print out the blank spaces of the word (Using underscores to represent letters) and came up with this:

public static char [] initializeDisplayedWord(char[] word)

//pre: recieves a char array representing a word

//post: returns a series of underscores representing the quantity of letters

{

int size = word.length;

char [] blankWord = new char[size-1];

for (int i=0; i
{

blankWord[i]= "_ ";

}

}

However, I rapidly...

Read More »

By: StackOverFlow - 6 days ago

Related Posts