第四章第十六题(随机字符)(Random character)
- 4.16(随机字符)编写一个程序,使用Math.random()方法显示一个随机的大写字母。
4.16(Random character) Write a program that displays a random lowercase letter using the Math.random() method. - 参考代码:
package chapter04;
public class Code_16 {
public static void main(String [] args){
System.out.println((char) ((int)(Math.random() * 26) + 65));
}
}
- 结果显示:
U
Process finished with exit code 0