除最后一个字符外,所有字符都应以逗号分隔。
示例输出:“猜测的先前字符:a、b、c、x”或“猜测的先前字符:a”
这是我所拥有的:
ArrayList<Character> charsGuessed = new ArrayList<Character>();
//takes in char guess from user
char guess=getCharacterGuess(in);
//adds char guessed to array
charsGuessed.add(guess);
int size=charsGuessed.size();
System.out.print("Previous characters guessed: ");
for(int i=0; i<size; i++)
{
if(i<=size-1)
{
System.out.print(charsGuessed.get(i) + " ");
}
else
{
System.out.print("," + " " + charsGuessed.get(i));
}
}