In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to use Java code to generate several random numbers of two-color balls". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Mavan pom file reference dependency
Cn.hutool hutool-all 5.3.6 com.google.guava guava 18.0
Java single-class implementation code, in the editor, paste the following code. Right mouse button, run running
Import cn.hutool.core.util.RandomUtil;import com.google.common.collect.Lists; import java.util.List; / * * @ Author tarzan * @ Date 14:43 on 2021-4-1 * @ Description simulates the two-color ball and randomly generates several residential numbers * / public class DoubleColorBall {/ * main method * * / public static void main (String [] args) {getDoubleColorBallNumber (5) } / * get multi-note two-color ball number * * / public static void getDoubleColorBallNumber (int num) {System.out.println ("randomly generated" + num+ "note two-color ball number is:"); String resultNumber= "; for (int I = 0; I < num; iTunes +) {System.out.println (" ["+ (iTun1) +"] "+ resultNumber+getDoubleColorBallNumber () }} / * get the single-note two-color ball number * * / public static String getDoubleColorBallNumber () {String resultNumber= "; for (int I = 0; I < 6; iTunes +) {String ballNumber= RandomUtil.randomEle (getRedBalls ()) +"; resultNumber=resultNumber+ballNumber;} return resultNumber+RandomUtil.randomEle (getBlueBalls ()) } / * get the collection of red ball numbers * * / public static List getRedBalls () {return getBalls (33);} / * get the collection of blue ball numbers * * / public static List getBlueBalls () {return getBalls (16);} / * get the collection of ball numbers * * / public static List getBalls (int num) {List redBalls= Lists.newArrayList () For (int I = 1; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.