zoukankan      html  css  js  c++  java
  • 第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);
        }
    }
  • 相关阅读:
    Android 红色小圆球提示气泡 BadgeView
    Android Studio .9图片的应用以及制作
    设置状态栏以及全局的颜色
    Mac 下 Git 的基础命令行操作
    [转]Android SDK下载和更新失败的解决方法
    Genymotion 常见问题Unable to configure the network adapter for the virtual device解决
    [转]eclipse的android智能提示设置
    IIS文件存在但报404问题解决
    [转]使用fdisk磁盘分区和 Linux 文件系统
    SQL Prompt 5.1使用
  • 原文地址:https://www.cnblogs.com/xiaoshubass/p/13602045.html
Copyright © 2011-2022 走看看