gpt4 book ai didi

android - 我这样写对吗? [小白]

转载 作者:行者123 更新时间:2023-11-29 18:24:36 27 4
gpt4 key购买 nike

 private final int NUM_SOUND_FILES = 4;
private Random rnd = new Random(4);
private int mfile[] = new mfile[NUM_SOUND_FILES]; //the second mfile
//reports error everytime
mfile[0] = R.raw.sound1;
mfile[1] = R.raw.sound2;
mfile[2] = R.raw.sound3;
mfile[3] = R.raw.sound4;

int sndToPlay = rnd.nextInt(NUM_SOUND_FILES);

不管我怎么写,我总是遇到语法错误。当我的语法正确时,它会强制关闭。这是所谓的“正确”语法但强制关闭:

private final int NUM_SOUND_FILES = 4;
private Random rnd = new Random(4);
private int mfile[] = new int[NUM_SOUND_FILES];{
mfile[0] = R.raw.sound1;
mfile[1] = R.raw.sound2;
mfile[2] = R.raw.sound3;
mfile[3] = R.raw.sound4;}

最佳答案

我不是 android 开发人员,但第 3 行的数组声明对我来说不合适,通常它是一个 int 类型的数组,声明如下:

private int[] mfile = new int[NUM_SOUND_FILES];

关于android - 我这样写对吗? [小白],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2816845/

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