java - Can't print a Random integer -


i have started learning java. learning "randomization" "kilobolt" tutorials. when ran code:

import java.util.random;   public class randomization {     public static void main (string[] args) {         random rand = new random();         rand.nextint(11);         system.out.println(rand);     } } 

the console displayed:

java.util.random@1888759

is supposed happen? or there errors in code?

( sorry if used wrong terms in question, i'm new website)

you're printing reference object rand. can either print out random number below:

public class randomization {     public static void main (string[] args) {         random rand = new random();         system.out.println(rand.nextint(11));     } } 

or can store in int before printing:

public class randomization {     public static void main (string[] args) {         random rand = new random();         int randomnumber = rand.nextint(11);         system.out.println(randomnumber);     } } 

either should work fine.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -