zoukankan      html  css  js  c++  java
  • java常用类

    public class Usuallyclass {
        public static void main(String[] args) {
    //        控制台输入
    //        Scanner scanner = new Scanner(System.in);
    //        int i = scanner.nextInt();
    //        System.out.println("刚才输入的数字是:"+i);
    
    //        随机数生成
    //        Random random = new Random();
    //        System.out.println(random.nextInt(10));//[0,10)
    
    //        遍历
    //        ArrayList<String> strings = new ArrayList<>();
    //        strings.add("linlong");
    //        strings.add("dingcaiyan");
    //        strings.add("linjincheng");
    //        for (int i = 0; i < strings.size(); i++) {
    //            System.out.println(strings.get(i));
    //        }
    
    //        字符串操作
    //        String str = "linlong";
    //        System.out.println("LINLONG".equalsIgnoreCase(str));
    //        System.out.println(str.substring(3, str.length()));//左开右闭
    //        System.out.println(str.replaceAll("l", "g"));
    //        String[] ls = str.split("l");
    //        for (int i = 0; i < ls.length; i++) {
    //            System.out.println(i + ":" + ls[i]);
    //        }
    
    //        数组工具类
    //        int[] arr = {5, 8, 3, 4, 9, 2, 7, 6, 1};
    //        System.out.println(Arrays.toString(arr));
    //        Arrays.sort(arr);
    //        System.out.println(Arrays.toString(arr));
    
    //        数学工具类
            double num = -6.18;
            System.out.println(Math.abs(num));//绝对值
            System.out.println(Math.ceil(num));//向上取整
            System.out.println(Math.floor(num));//向下取整
            System.out.println(Math.round(num));//四舍五入
        }
    }
    public class UsusallyUseClass {
        public static void main(String[] args) throws ParseException {
    //        日期操作
    //        long currentTimeMillis = System.currentTimeMillis();
    //        Date date = new Date(System.currentTimeMillis() - (1000L * 60 * 60 * 24 * 365));
    //        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
    //        Date parse = new SimpleDateFormat("yyyy-MM-dd").parse("2020-08-14");
    
    //        日历操作
    //        Calendar calendar = Calendar.getInstance();
    //        Date date = calendar.getTime();
    //        int year = calendar.get(Calendar.YEAR);
    //        calendar.set(Calendar.YEAR, 2019);
    //        calendar.add(Calendar.YEAR, -1);
    
    //        数组复制
    //        int[] ints = {5, 8, 3, 4, 9, 2, 7, 6, 1};
    //        int[] intscopy = new int[ints.length];
    //        System.arraycopy(ints, 0, intscopy, 0, ints.length);
    //        System.out.println(Arrays.toString(intscopy));
    
    //        字符串缓冲区
    //        StringBuilder stringBuilder = new StringBuilder("hello");
    //        StringBuilder append = stringBuilder.append(" world");
    //        System.out.println(append.toString());
    //        System.out.println(append == stringBuilder);
    
    //        字符串转数字
            int parseInt = Integer.parseInt("1994");
            Integer integer = Integer.valueOf("2001");
        }
    }
    // 参数验证是否为空
    // String field = null;
    // Objects.requireNonNull(field, "传递的对象为空");
    
    // 判断末尾字符串
    // System.out.println("aaabbbcccddd".endsWith("ddd"));
    
    //编码
    //URLEncoder.encode(String, "utf-8");
    //解码
    //URLDecoder.decode(String, "utf-8");
  • 相关阅读:
    [野外实验] 塞罕坝遥感实验(2020.7-8月)
    [学术论文] 一时兴趣的产出(新型TLS布站策略)被TGRS录用
    c++11 新特性实战 (一):多线程操作
    用 Docker Swarm 来部署 Nebula Graph 集群
    用图机器学习探索 A 股个股相关性变化
    图数据库对比:Neo4j vs Nebula Graph vs HugeGraph
    【程序人生】25岁,一位女程序员的幸运几年
    【开发总结】order by 为什么没有走索引?
    【故障总结】CPU飙升?我写的?
    mysql比现实时间少了八小时
  • 原文地址:https://www.cnblogs.com/linding/p/13493324.html
Copyright © 2011-2022 走看看