zoukankan      html  css  js  c++  java
  • 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();

  • 相关阅读:
    张艾迪:全面开放“A"计划
    张艾迪(创始人):我们是激情与开放的世界
    张艾迪(创始人):由产品集合到创新的引领
    张艾迪(创始人):Be.Time+Cr.Idear的创新理念
    张艾迪(创始人): 整合全新的UIW.AD概念
    张艾迪(创始人): 整合全新的UIW.AD概念模式
    腾讯会员免费领取试用免费腾讯视频vip共享
    golang二进制bit位的常用操作
    golang ntp协议客户端
    imagecreatefrombmp、imagebmp php处理bmp文件
  • 原文地址:https://www.cnblogs.com/weixiaole/p/4514987.html
Copyright © 2011-2022 走看看