gpt4 book ai didi

java - 由于某种原因, paint() 被调用了两次

转载 作者:行者123 更新时间:2023-11-29 03:22:03 26 4
gpt4 key购买 nike

<分区>

这是我的代码:

public class Circles extends JApplet{
public void paint(Graphics g) {

Scanner in = new Scanner(System.in);
Random rand = new Random();

int position = rand.nextInt(200);

System.out.println(position);
}
}

输出是:

199

152

发生的事情是在打印出“position”变量后,它跳回并重新开始。我不明白为什么会这样。

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