가능한 중복 :
The most sophisticated way for creating comma-separated Strings from a Collection/Array/List?구분 문자
모든 문자를 마지막 문자 제외 쉼표로 구분한다.
예 출력 : "이전 문자는 추측 : A, B, C, X"또는 "추측 이전 문자 :는"
내가 가진 Heres는 무엇을 :
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));
}
}
무슨 질문을? –
http://stackoverflow.com/questions/205555/themost-sophisticated-way-for-creating-comma-separated-strings-from-a-collectio 도움이 될 수 있습니다. – andyb
질문의 세부 사항을 개선해야합니다. 한 줄로 ... 정말? – MUG4N