Java-常用包与函数
Math.random()
Math.random()会返回一个[0.0,1.0)的双精度浮点数(Math.random()*51)就是返回一个[0.0,51.0)的双精度浮点数
固:(int)(Math.random()*51)是返回[0,50]的随机整形
(Math.random()*51)就是返回一个[0.0,51.0)的双精度浮点数
固:(int)(Math.random()*51)是返回[0,50]的随机整形
1 | public class Main { |
用法:
1 | Scannner scan = new Scanner(System.in); |
读入流类型
注:next()后直接继续使用nextLine()回到是后者返回NULL,徐涛需要手动额外调动一次nextLine()以清除换行符
1 | System.out.Print("字符串1"+a+"字符串2"); |
特殊字面量:
%t //制表符,在打印时将前面字符串的长度补齐到8或8的整数倍
1 | int[] a = {0}; //声明一个长度为1、初始值为0的数组 |