Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 2
配列のマージ | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 17
配列のマージ
配列と配列をマージして一つの配列にします。
System.arraycopyメソッドを使用すると簡単に実現できます。

サンプルソース
public static Object[] merzeArray(Object[] obj1,Object[] obj2){

    Object[][] obj = new Object[2][];
    obj[0] = obj1;
    obj[1] = obj2;
    
    if(obj[0] == null && obj[1] == null){
        return new Object[0];
    }else if(obj[0] == null){
        return obj[1];
    }else if(obj[1] == null){
        return obj[0];
    }
    
    int size = 0;
    for (int i=0; i<obj.length; i++) {
        size += obj[i].length;
    }

    Object[] returnObj = new Object[size];

    int point = 0;
    for (int i=0; i<obj.length; i++) {
        System.arraycopy(obj[i], 0, returnObj, point, obj[i].length);
        point += obj[i].length;
    }
    return returnObj;
}

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 96

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 96

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 105

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/array/array_merze/array_merze.html on line 105