mardi 16 février 2021

How to pull random string from a keySet?

I'm working on a problem in which I need to pull a random String from a keySet. Just wondering if anyone can give me some direction here. I'm pretty lost on it. I've found quite a few ways to do it if I were using an int, but not a String. For example I want to quiz a user on States and their Capitals, and to pull out a random Key from the keySet for the question. Here's the set:

Set<String> states = stateCapitals.keySet();



Aucun commentaire:

Enregistrer un commentaire