检查堆栈数组中的所有值在JAVA中是否相同

检查堆栈数组中的所有值在JAVA中是否相同,java,libgdx,Java,Libgdx,我在libGDX框架中创建以下代码: public class Play implements Screen { private Stack<Integer>[][] intStack; @Override public void show() { ..... // Initializations intStack = new Stack[3][3]; for (int row = 0; row &

我在libGDX框架中创建以下代码:

public class Play implements Screen {

    private Stack<Integer>[][] intStack;

    @Override
    public void show() {
        .....
    // Initializations
        intStack = new Stack[3][3];

        for (int row = 0; row < btnSquares.length; row++) {
            for (int col = 0; col < btnSquares[0].length; col++) {

       // generate integer number randomlly

                num = new Random().nextInt(9) + 1;

                intStack[row][col] = new Stack<Integer>();
                intStack[row][col].push(num);

                .......
            }
        }

    }

.........

}
公共类播放屏幕{
私有堆栈[][]intStack;
@凌驾
公开展览({
.....
//初始化
intStack=新堆栈[3][3];
对于(int row=0;row

pop()之后
push()修改某些值的方法。。如何检查数组中所有堆栈中的所有值是否相等?

Stack.equals
将告诉您两个堆栈的大小是否相等,并且在相应位置的元素是否相等。您还需要其他的吗?另外,我假设
btnSquares.length==3&&btnSquares[0]。length==3
,或者您实际上打算使用
新堆栈[btnSquares.length][btnSquares[0]。length]
?(类似地,对于
9=>btnSquares.length*btnSquares[0].length
),如果希望在每个int堆栈中保证不同的值,则更容易1)将数字1-n放入ArrayList;2) 使用
Collections.shuffle
随机排列顺序;3) 依次将列表中的元素分配给堆栈。Thx用于应答。我想检查所有堆栈是否具有相同的值(堆栈内的这些值,我的意思是..不是堆栈的大小)。以下图像解释了我想要的:1)第一个图像堆栈值不相等2)第二个img堆栈具有相同的值。。thanx
Stack.equals
将告诉您两个堆栈的大小是否相等,并且在相应位置的元素是否相等。您还需要其他的吗?另外,我假设
btnSquares.length==3&&btnSquares[0]。length==3
,或者您实际上打算使用
新堆栈[btnSquares.length][btnSquares[0]。length]
?(类似地,对于
9=>btnSquares.length*btnSquares[0].length
),如果希望在每个int堆栈中保证不同的值,则更容易1)将数字1-n放入ArrayList;2) 使用
Collections.shuffle
随机排列顺序;3) 依次将列表中的元素分配给堆栈。Thx用于应答。我想检查所有堆栈是否具有相同的值(堆栈内的这些值,我的意思是..不是堆栈的大小)。以下图像解释了我想要的:1)第一个图像堆栈值不相等2)第二个img堆栈具有相同的值。。塔克斯