zoukankan      html  css  js  c++  java
  • JAVA常用代码

    一. 判断是否包含某个注解。
        1). 声明接口

    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.TYPE)
    @Documented
    public @interface HandlesAsynchronously {
    
    }
    

     2). 判断是否包含当前注解。

    // 判断是否需要异步执行。
                Boolean isAsync = false;
                Annotation[] annotations = handler.getClass().getAnnotations();
                for (Annotation x : annotations) {
                    if (x.annotationType() == HandlesAsynchronously.class) {
                        isAsync = true;
                        break;
                    }
                }
    

     3). java Stream toarray

    Integer 数组: toArray(Integer[] :: new)
    person 数组: toArray(person[] ::  new).
    

     4). fashjson反序列化泛型对象。

     BasePlatResponse<StorageBatchDeliveryResponseBizData> successResponse = JSON
                    .parseObject(successJson, new TypeReference<BasePlatResponse<StorageBatchDeliveryResponseBizData>>() {
                    });
    

     5). java中的前加加++和后加加++
         前++是先自加再使用 (++i)
        后++是先使用再自加 (i++)

  • 相关阅读:
    第二阶段冲刺7
    第二阶段冲刺6
    课后作业02需求分析
    阅读计划
    个人总结
    第十六周学习进度条
    第十五周学习进度条
    《梦断代码》阅读笔记03
    《梦断代码》阅读笔记02
    《梦断代码》阅读笔记01
  • 原文地址:https://www.cnblogs.com/mrhgw/p/8067085.html
Copyright © 2011-2022 走看看