0
我有一個Label
s的二維數組,每個標籤包含一個int
的String
版本。我試圖遍歷我的數組,並檢查每個元素是否包含相同的int
。我是否以這種錯誤的方式去做?嘗試比較標籤的二維陣列的多個連續元素
public boolean isPattern(Label[][] matirx) {
boolean pattern = false;
for (int rPos = 0; rPos < rows; rPos++) {
for (int cPos = 0; cPos < columns - 3; cPos++) {
if (matrix[cPos][rPos].equals(matrix[cPos + 1][rPos])
&& matrix[cPos][rPos].equals(matrix[cPos + 2][rPos])
&& matrix[cPos][rPos].equals(matrix[cPos + 3][rPos])) {
pattern = true;
}
}
}
當我打印我的boolean
到輸出窗口,我得到false
不管。所以我想我真正的問題是。我是比較每個Label
的內容還是每個索引的值,從而導致變量永遠不是true
?