• Array


    int[] x = new int[100];

    int[] x = new int[]{1,2,3,4};//不要给数组定义大小

    int[] x = {1,2,3,4};//上面的简写

    int[] x = new int[3][];//但使用的时候要把后面的值补上 定义有几个一维数组

    x[0] = new int[3];

    x[1] = new int[4];

    x[2] = new int[3];

    /**
         * 查询Redis数据库
         * @return
         */
        
        public String[][][] selectFromRedis(String field,String value){
            log.info("执行selectFromRedis方法");
            long startTime=System.currentTimeMillis();  
            Set<String> setCluster = new HashSet<String>();
            Set<String> set80 = new HashSet<String>();
            set80 = jedis.keys("*");
            Iterator<String> it1 = set80.iterator();  
            while (it1.hasNext()) {  
              String str = it1.next();  
              System.out.println(str+"----6380");  
            }
            setCluster.addAll(set80);
            Map map = new HashMap();
            Map map1 = new HashMap();
            Set mapAll = new HashSet();
            try {
                long startTime2=System.currentTimeMillis();
                Iterator<String> itAll = setCluster.iterator();  
                log.info("获得的所有key的个数  :"+setCluster.size());
                while (itAll.hasNext()) {
                    String str = itAll.next();
                    log.info(str+"===========================");
                    //System.out.println(value.equals(rec.hget(str, field))+"&&&&&&&&&&&&&&&&&&&&");
                    log.info(System.currentTimeMillis());
                    if(value.equals(jedis.hget(str, field))){                
                        map = (Map) jedis.hgetAll(str);
                        //System.out.println(map);
                        mapAll.add(map);
                        log.debug(mapAll);
                        //System.out.println(str+"----setCluster");
                    }
                    log.info(System.currentTimeMillis());
                    log.info("比较一个map中字段程序运行时间: ms");
                }
                long endTime2=System.currentTimeMillis();
                log.info("比较所有map中字段程序运行时间: "+(endTime2-startTime2)+"ms");
                 
            } catch (Exception e) {
                log.info("selectFromRedis中的异常");
                e.printStackTrace();
                String[][][] fail = {{{"-1"}},{{"-1"}},{{"-1"}}};
                return fail;
            }
            
            log.info(mapAll.size()+"有多少条符合的记录#####################mapAll.size()");
            String[][][] ObjectMapAll = null;
            Iterator<Map> it3 = mapAll.iterator();                                                   
             int j = 0;
             ObjectMapAll = new String[mapAll.size()][][];
            while (it3.hasNext()) {
                 map1 = it3.next(); 
                 //关键是这个值entrySet.size()在循环外面得不到
                 Set<Map.Entry<String, String>> entrySet = map1.entrySet();              
                 Iterator<Map.Entry<String, String>> itMap = entrySet.iterator();
                // System.out.println(entrySet.size());             
                 String[][] ObjectMap = new String[entrySet.size()][];
                  int i = 0; 
                  while(itMap.hasNext()){
                      String[] arr = new String[2];
                      Map.Entry<String, String> me = itMap.next();
                      String key1 = me.getKey();
                      String value1 = me.getValue();
                      arr[0] = key1;
                      arr[1] = value1;
                      ObjectMap[i] = arr;
                      ObjectMapAll[j] = ObjectMap;
                      log.info("selectFromRedis方法中"+"key: "+key1+"-->value: "+value1);
                      i++;                 
                  }              
                  j++;
                  log.info(j+"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
                }
            for (int i = 0; i < ObjectMapAll.length; i++) {         // 遍历数组  
                for (int j1 = 0; j1 < ObjectMapAll[i].length; j1++) {  
                    for (int k = 0; k < ObjectMapAll[i][j1].length; k++) {  
                        log.info(ObjectMapAll[i][j1][k] + "	");  
                    }  
                    System.out.println();                       // 输出一维数组后换行  
                }  
            }
                return ObjectMapAll;
            }

    api

    Array.sort();

    Array.binarySearch();

    Array.fill();数组的初始化 指定初始值

    Array.copy();

  • 相关阅读:
    hdu 1251(字典树)
    关于sass和less做自适应网页的区别
    重置css样式
    打印网页局部内容的方法
    关于在IE下面promise兼容的解决办法
    关于vue属性绑定的问题
    vue的过渡动画在除了chrome浏览器外的浏览器下不正常的问题
    jq 的replaceWith方法在360下面会出现兼容问题
    element-ui 的 upload组件的clearFiles方法调用方法
    canvas 转化为 img
  • 原文地址:https://www.cnblogs.com/weixiaole/p/4514987.html
Copyright © 2020-2023  润新知