• 第11节:Java API 基础一【多测师_王sir】


    package com.xuexi;
    
    import javafx.scene.control.ProgressBar;
    
    import java.util.Arrays;
    import java.util.Properties;
    
    public class Lesson16 {
        public static void main(String[] args) {
            int [] sz1 = {78,34348,1,23,567,2343,7038872};
            int [] sz2 = new int[7];
            int [] sz3 = {1,2,5,34};
            int [] sz4 = {1,2,5,34};
    
            // 在使用binarySearch之前必须对数组进行排序
            // Arrays.sort:对数组进行升序排序
            Arrays.sort(sz1);
            System.out.println(Arrays.toString(sz1));
            // 查找数值在数组中的索引位置,如果不存在返回的值小于0
            int a1=Arrays.binarySearch(sz1,4);
            System.out.println(a1);
            // 判断该值是否存在这个数组
            if(a1>=0){
                System.out.println("该值在数组中存在索引位置");
            }else{
                System.out.println("该值在数组中不存在");
            }
            // 将指定的一个值分配给指定数组的每个元素。
            Arrays.fill(sz2,77);
            System.out.println(Arrays.toString(sz2));
            //查看数组的内存地址
            //查看数组的内存地址(十进制显示)
            int a3=sz3.hashCode();
            int a4=sz4.hashCode();
            System.out.println(a3);
            System.out.println(a4);
            //查看数组的内存地址(十六进制显示)
            String a5=Integer.toHexString(sz3.hashCode());
            String a6=Integer.toHexString(sz4.hashCode());
            System.out.println(a5);
            System.out.println(a6);
            //对比两个数是否相等
            boolean a7=sz3.equals(sz4);
            System.out.println(a7);
            //StringBuffer与StringBuildr基本用法相同。
            // 不同点:StringBuffe:线程安全,性能相对差。StringBuildr:线程不安全,性能相对好。
            //append:追加字符串
            StringBuffer stringBuffer =new StringBuffer();
            stringBuffer.append(666);
            stringBuffer.append('我');
            stringBuffer.append("是学生");
            stringBuffer.append(Arrays.toString(sz3));
            System.out.println(stringBuffer);
            //reversec:字符串反串
            StringBuffer a8=stringBuffer.reverse();
            System.out.println(a8);
            // System 类
            //复制数组
            int [] sz5 = new int[7];
            int [] sz6 = {78,48,1,23,57,23,38};
            System.arraycopy(sz6,2,sz5,2,3);
            System.out.println(Arrays.toString(sz5));
            // 获取当前时间的毫秒数
            long a9=System.currentTimeMillis();
            System.out.println(a9);
            for (int i = 0; i <9000 ; i++) {
                System.out.print(i);
            }
            System.out.println();
            // 获取循环9000次之后时间的毫秒数
            long a10=System.currentTimeMillis();
            System.out.println(a10);
            // 获取循环9000次之后两次时间的差毫秒数
            System.out.println(a10-a9);
            // 获取系统属性
            Properties a11=System.getProperties();
            System.out.println(a11);
            // 退出虚拟机(下面的程序不运行)
            //System.exit(1);
            //identityHashCode 返回给定对象的哈希码(内存地址)
            String str1="123";
            String str2=new String("123");
            int a12=System.identityHashCode(str1);
            int a13=System.identityHashCode(str2);
            System.out.println(a12);
            System.out.println(a13);
        }
    }
  • 相关阅读:
    清北学堂模拟赛d6t1 角谷猜想
    清北学堂模拟赛d4t1 a
    清北学堂模拟赛d3t6 c
    清北学堂模拟赛d3t5 c
    清北学堂模拟赛d3t4 a
    清北学堂模拟赛d3t3 c
    清北学堂模拟赛d3t1 a
    清北学堂模拟赛d2t3 逆序对(pair)
    Android(java)学习笔记176: 远程服务的应用场景(移动支付案例)
    Android(java)学习笔记175:Android进程间通讯(IPC)之AIDL
  • 原文地址:https://www.cnblogs.com/xiaoshubass/p/13602045.html
Copyright © 2020-2023  润新知