zoukankan      html  css  js  c++  java
  • list集合转String类型,并拿出所有对象

    例子:

      public static void main(String[] args) {
    
        ArrayList<String> arrayList = new ArrayList<String>();
        arrayList.add("啊哈哈");
        arrayList.add(" 反 ");
        arrayList.add(" 对 ");
        arrayList.add(" 胜利 ");
        arrayList.add(" 厉害 ");
        String[] str = new String[10];
        for (int i = 0; i <= 10; i++) {
          arrayList.add(String.valueOf(i));
    
    
        }
    
        String arr = arrayList.toString();
        String arrys = "";
        int count = 0;
        for (int i = 0; i <= arr.length(); i++) {
          if (i == 0) {
            String substring = arr.substring(arr.lastIndexOf(',') + 1, arr.length() - 1);
            arrys = substring;
            arr = arr.substring(1, arr.lastIndexOf(','));
          }
          if (i > 0 && i < 2) {
            for (int b = 0; b <= arrayList.size(); b++) {
              // 0, 2, 4, 6, 8
              String substring = arr.substring(arr.lastIndexOf(',') + 1, arr.length());
              if(!substring.contains(" ")){
                  arrys = arrys + " " +substring;
              }else{
                  arrys = arrys + substring;
              }
              arr=arr.trim();
              if (!arr.contains(",")) {
                break;
              }
                System.out.println(arr.length());
              arr = arr.substring(0, arr.lastIndexOf(','));
            }
          }
        }
        if(arrys.contains("0")){
          System.out.println("已有子集");
        }
          System.out.println(arrys);
        //
      }
    

      

  • 相关阅读:
    OCP-1Z0-051-V9.02-55题
    OCP-1Z0-051-V9.02-60题
    OCP-1Z0-053-V12.02-59题
    OCP-1Z0-053-V12.02-184题
    OCP-1Z0-053-V12.02-595题
    OCP-1Z0-053-V12.02-584题
    OCP-1Z0-053-V12.02-234题
    OCP-1Z0-053-V12.02-548题
    OCP-1Z0-053-V12.02-549题
    OCP-1Z0-053-V12.02-551题
  • 原文地址:https://www.cnblogs.com/money131/p/13306958.html
Copyright © 2011-2022 走看看