简体   繁体   中英

How to display random numbers in jlabel?

I need how to Display Random number in JLabel Java I used

Random sum1 = new Random();

jLabel1.setText(random1);

Random is a class used to generate random numbers - you need to use it by calling one of its nextWhatever methods:

Random r = new Random();
jLabel1.setText(String.valueOf(r.nextInt());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM