数组、时间、随机数


import java.util.*;
public class T5 {
 public static void main(String[] args)
 {
   
      int[] arr={15,5,87,7,53};
   int[] arr2=new int[5];
   //ystem.arraycopy(arr,0,arr2,0,5);
   arr2=arr;
   arr[1]=1;
   for (int i=0;i<arr2.length ;i++ )
   {
    System.out.println("arr2:"+arr2[i]+" ");
   }
   System.out.println();
   for (int i=0;i<arr.length ;i++ )
   {
    System.out.println("arr:"+arr[i]+" ");
   }
   //Arrays.fill(arr,8);
   /*//Arrays.sort(arr);
   //int a=Arrays.binarySearch(arr,15);
   //System.out.print("\n"+a+" ");
   System.arraycopy(arr,0,arr2,0,arr2.length);
   */
 }
 
}
import java.util.*;
import java.text.*;
public class Test7 {
 public static void main(String[] args)
 {
  //Date转换成字符串
  Date date = new Date();
  System.out.println("系统时间:"+date);
  SimpleDateFormat sp1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ;
  System.out.println(sp1.format(new Date())) ;
  //字符串转换成Date
  try{
   Date d = sp1.parse("2014-12-25 14:25:50");
   SimpleDateFormat sp2 = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒") ;
   System.out.println(sp2.format(d)) ;
  }catch(ParseException e){
   e.printStackTrace();
  }
 
 }
}

//ceil天花板 floor地板
  /*double d = Math.ceil(2.11);
  double e = Math.floor(2.11);
  System.out.println(d);
  System.out.println(e);
 
  int a =9;
  int b=10;
  System.out.println(Math.min(a,b));
  //round四舍五入
  System.out.println(Math.round(2.5));
  System.out.println("随机数:"+Math.random());
  double g = Math.random();
  System.out.println(g);
  System.out.println(g*9);
  System.out.println(g+1);
  System.out.println((g*9+1)*100000);
  System.out.println(Math.round((g+1)*100000));
  //随机数
  long r1 = (long)((Math.random()*9+1)*1000000000);
  int r2 = (int)((Math.random()*9+1)*100000);
  System.out.println("10位随机数"+r1);
  System.out.println("6位随机数"+r2);*/
  /*for(int i=0;i<100;i++){//0.011
   System.out.println(Math.round((Math.random()*9+1)*100000));
  }*/
  Random r = new Random();
  for(int i=0;i<100;i++){
   System.out.println(r.nextInt(100));
  }
double d = Math.round(-1.9);
  double e = Math.ceil(-2.11);
  double f = Math.floor(-2.11);
  System.out.println("-2.11向上取整"+e);
  System.out.println("-2.11向下取整"+f);



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值