Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 Eclipse 中开发一个应用程序,当单击按钮时随机显示字符串中的文本。
有一个简单的解决方案。您使用 Random() 类或使用 Math.random() 将字符串作为字符数组进行迭代。然后你只需选择它的随机位,直到它消失。
不过,您必须确保始终检查数组大小,以免遇到 OutOfBoundsException