gpt4 book ai didi

java - 随机数字串

转载 作者:行者123 更新时间:2023-12-01 17:25:18 25 4
gpt4 key购买 nike

我想打印一串数字,但我得到以下结果:[I@7c230be4

这是我的代码:

import java.util.Random;

class Aleatorio {
public static void main(String[] args) {
Random diceRoller = new Random();
int cifra[]= new int[5];
for (int i = 0; i < cifra.length; i++) {
int roll = diceRoller.nextInt(9)+1 ;
cifra[i]=roll;
}
System.out.println(cifra);
}
}

最佳答案

您将看到 int 数组 ObjectObject#toString 表示形式。要显示其内容,您可以使用:

Arrays.toString(cifra)

关于java - 随机数字串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15441172/

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