Вот смотрю пример кода и нашел тут вот такое
public static List<Word> detectAllWords(int[][] crossword, String... words) {
List<Word> wordList = new ArrayList<>();
int[][] searchDirections = new int[][] {
{0, 1},
{1, 1},
{1, 0},
{1, -1},
{0, -1},
{-1, -1},
{-1, 0},
{-1, 1},
};
for (String word : words) nextWord:{
for (int i = 0; i < crossword.length; i++) {
for (int j = 0; j < crossword[i].length; j++) {
if (word.charAt(0) == crossword[i][j])
for (int directions = 0; directions < searchDirections.length; directions++) {
int tmp_i = i,
tmp_j = j,
wordPos = 1;
while (wordPos < word.length()) {
tmp_i += searchDirections[directions][0];
tmp_j += searchDirections[directions][1];
if (tmp_i < 0 || tmp_i >= crossword.length || tmp_j < 0 || tmp_j >= crossword[tmp_i].length)
break;
if (word.charAt(wordPos) != crossword[tmp_i][tmp_j])
break;
else if (wordPos == word.length() - 1) {
Word tWord = new Word(word);
tWord.setStartPoint(j, i);
tWord.setEndPoint(tmp_j, tmp_i);
wordList.add(tWord);
break nextWord;
}
wordPos++;
}
}
}
}
}
return wordList;
}
Так вот первый раз вижу вот такое условие
for (String word : words) nextWord:{
и потом это как то привязано к строке ниже
break nextWord;
подскажите как это работает или где есть что почитать?
Свежие комментарии