• 将一维数组存到二维数组 、将一维数组存到列表


    public class Test0202 {
    
        public static void main(String[] args) throws ParseException {
          
            //将一维数组加入到二维数组
            //二维数组
            String arr[][] =  new String[3][]; 
            //一维数组
            String name[] = {"zs","ls","ww"};
            String nick[] = {"z1","l2","w3"};
            String pass[] = {"a123","l123","w123"};
            arr[0]=name;
            arr[1]=nick;
            arr[2]=pass;
            //遍历
            for(String x1[]:arr) {        
                for(String x:x1) {
                    System.out.print(x+"	");
                }
                System.out.println();
                
            }
        }
    
    }

    结果

    zs    ls    ww    
    z1    l2    w3    
    a123    l123    w123

    将一维数组存到列表

        //一维数组
            String name[] = {"zs","ls","ww"};
            String nick[] = {"z1","l2","w3"};
            String pass[] = {"a123","l123","w123"};
            
            List<String[]> array= new ArrayList<String[]>();
            array.add(name);
            array.add(nick);
            array.add(pass);
            
            for(String x1[]:array) {        
                for(String x:x1) {
                    System.out.print(x+"	");
                }
                System.out.println();
                
            }

    结果:

    zs    ls    ww    
    z1    l2    w3    
    a123    l123    w123    
  • 相关阅读:
    C#编程技巧之钩子函数的使用——SetWindowsHookEx
    JSON(Ajax)和JsonP
    C#对象与方法
    C#数据类型
    事务处理
    面向对象之继承与多态
    C#编程语言简介
    <转>成员函数的重载、覆盖与隐藏
    视图、索引
    C#方法
  • 原文地址:https://www.cnblogs.com/ychun/p/14283107.html
Copyright © 2020-2023  润新知