RT,最近刚买了笔记本,硬盘吱吱响实在受不了,该不该上ssd?
今晚的作业:
- package day18;
- /**
- * @author always
- *
- * ceil(double d) 返回大于等于指定数据的最小整数;
- * floor(double d) 返回小于等于指定数据的最大整数;
- * round(double或long) 四舍五入
- * pow(double a,double b) 返回a的b次幂;
- * random() 随机获取0~1(包含0,不包含1)之间的数字; 伪随机数
- * Random random = new Random();
- * random。nextInt(10);//返回0~10之前的伪随机数;
- */
- public class MathDemo {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- double ceil = Math.ceil(12.34);// ceil返回大于制定数据 的最小整数
- double d1 = Math.floor(12.34);// floor返回小于指定数据的最大整数;
- long l = Math.round(12.34);//四舍五入
- double pow = Math.pow(8,2);
-
- System.out.println("ceil=" + ceil);
- System.out.println("d1=" + d1);
- System.out.println("l=" + l);
- for(int i=0;i<10;i++) {
- int random = (int)(Math.random()*10+1); //随机获取0~1之间
- System.out.println("random=" + random);
- }
- System.out.println("pow=" + pow);
-
- }
- }
复制代码
- /*
- IO流学习
- */
- import java.io.*;
- public class FileWriterDemo {
- public static void main(String[] args) {
- FileWriter fw = null;
- try {
- fw = new FileWriter("Demo.txt");
- fw.write("This is my first file be created by java!");
- }
- catch(IOException e) {
- System.out.println(e);
- }
- finally {
- try {
- if(fw != null)
- fw.close();
- }
- catch(IOException e) {
- System.out.println(e);
- }
- }
- }
- }
复制代码
|