新手自学java,碰见问题求解答,

新手自学java,碰见问题求解答,,第1张

import java.util.*

public class HelpTest {

public static void main(String[] args) {

Random suijishu = new Random()

Scanner saomiaoyi = new Scanner(System.in)

System.out.println("请输入个数:")

int timu = saomiaoyi.nextInt()

int[][] da = new int[timu][timu]//定义数组时链裂凳未使用数组源缓长度,随机数>3导致数组越界

timu = da.length

for (int a = 0a <timua++) {

for (int i = 0i <timui++) {

da[a][i] = suijishu.nextInt(timu) + 1

}

}

for (int b = 0b <timub++) {

for (int c = 0c <timuc++) {

System.out.println(da[b][c])

}

}

}

}

这个是更改过的你对棚旅比对比,然后class文件名 不要用中文,用英文,每个单词首字母大写

public static 薯烂Geocache[] createGeocaches(int a) {

        if(a <= 0) return new Geocache[0]

        Random rand = new Random()

        Geocache[] result = new Geocache[a]

        for(int i = 0 i 模扮< a i++) {

                //因为题目没有描述,这里假设x, y是随机整数,Geocache有构造函数(int, int)

                int x = rand.nextInt()

                int y = rand.nextInt()

                result[i] = new Geocache(x, y)

        }

  数码漏      return result

}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12512583.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2025-08-25
下一篇2025-08-25

发表评论

登录后才能评论

评论列表(0条)

    保存