안녕 얘들 아 나는 자바에 대해 매우 익숙하지 않다. 왜 누군가가 내 배열의 시작 부분에 무작위 null을 얻었는지 설명 할 수 있는지 궁금하다. [null, r, b] , O, e, r, t] 왜 그렇게하는지 모르겠다! 어떤 도움이 그것을 없애 버리는 것은 굉장 할 것입니다!.split()을 사용할 때 null
public static String [] Wordarray(Scanner input)
{
String [] temp = {};
String word = "";
do{
System.out.println("Enter a word you'd like to be guess");
word = input.nextLine().toLowerCase();
if(word.length()<5)
System.out.println("Error....");
}while(word.length()<5);
String [] words = word.split("");
return words;
}
미리 감사드립니다.
example input to output Enter a word you'd like to be guess
beees
The word contains 6letters.
Amount of chances left 7
avaliable letters : [, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]
Enter a letter :
b
[]
[-, b, -, -, -, -]
[null, b, null, null, null, null]
Amount of chances left 7
avaliable letters : [, a, , c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]
Enter a letter :
e
[-, b, -, -, -, -]
[-, -, e, e, e, -]
[null, b, e, e, e, null]
Amount of chances left 7
Enter a letter :
s
[-, -, e, e, e, -]
[-, -, -, -, -, s]
[null, b, e, e, e, s]
Amount of chances left 6
은 우리에게 예를 들어 입력을 지정합니다. –
배열에 첫 번째 요소로 'null'이 포함 된 배열도 표시하십시오. –
왜'char [] words = word.toCharArray();' –