How to display random numbers in jlabel?

2.2k Views Asked by At

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

Random sum1 = new Random();

jLabel1.setText(random1);
1

There are 1 best solutions below

0
On

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());