gpt4 book ai didi

java - 如何创建随机分布在阵列上的图像的 2D 阵列?

转载 作者:行者123 更新时间:2023-11-30 03:23:03 28 4
gpt4 key购买 nike

我想在我的小程序中创建一个二维图像数组。我需要一个 4x4 网格,其中有 4 个图像,每个图像 4 个随机分布在阵列中。这里有一些答案,但我不明白如何使用它们。

最佳答案

您可以声明

Image[][] myImages = new Image[4][4]

然后为其分配一个值,如下所示。

myImages[0][1] = "image1"
......

或者你可以使用循环,

for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
myImages[i][j] = "whatever to get your image"
}
}

关于java - 如何创建随机分布在阵列上的图像的 2D 阵列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30881571/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com