I am writing a script using 'java.util.Random' and I am trying to initialize two random variables for the same println but it only works if I comment out one of the variables. Here is the code where my problem is:
Random a = new Random();
date = a.nextInt(29) + 1;
year = a.nextInt(2019 - 2044)+ 1;
System.out.println("The best day of your life will be on " + month + " " + date + ","+ " " + year + ".....give or take.\n");
System.out.println("Which date of the month do you believe is your luckiest?");
I can't figure out how to initialize 'date' and 'year' at the same time. Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire