vendredi 30 décembre 2022

How to print random character from string in Java [duplicate]

I'm working on a project that you try to find the full word. There is an option that gives you a clue. The clue is printing individual characters from random index. but sometimes I am accesing same characters. I dont want to print duplicate characters (from same index). For example the word is computer. When I press the clue button, character from 2nd index reveals. But when I press again, random number chooses 2nd index again randomly. I dont want to acces 2nd index anymore. How can I do that? Thanks.

I tried to create an array list to store random indices. And I created a for loop to check all the elements of the array list to avoid same indices. But its not working or I couldnt make it.




Aucun commentaire:

Enregistrer un commentaire