public List generateCircles() { List circles = new ArrayList<>(); String[] colors = {'red', 'green', 'blue'}; Random random = new Random(); for (int i = 0; i < 20; i++) { int radius = random.nextInt(10) + 1; String color = colors[random.nextInt(3)]; // 随机选择一种颜色 Circle circle = new Circle(radius, color); circles.add(circle); } return circles; }

Java 生成随机圆形列表:半径、颜色随机

原文地址: https://www.cveoy.top/t/topic/oipj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录