I'm trying to read in random numbers and convert them into a date. I tried doing it for a first number using java.util.date and ThreadLocalRandom. It say's 'The local variable d1 may not have been initialized'
import java.util.concurrent.ThreadLocalRandom;
import java.util.Date;
public class TestDate {
public static void main(String[] args) {
Date d1 = new Date(ThreadLocalRandom.current().nextLong(d1.getTime()));
System.out.println("Today's date is: " + d1.toString());
System.out.println("Milliseconds: " + d1.getTime());
}
}
When I'm just setting d1 as a variable it says 'Duplicate local variable d1'
I don't get where my mistake is
Aucun commentaire:
Enregistrer un commentaire