首頁 >後端開發 >php教程 > java代码转PHP代码

java代码转PHP代码

WBOY
WBOY原創
2016-06-13 13:04:051039瀏覽

java代码转PHP代码,高手进

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayAssemble {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		String[] arrOfInt = { "红", "橙", "黄","黑" };
		@SuppressWarnings("unused")
		String[] arrOfChar1 = { "L", "XL" };
		@SuppressWarnings("unused")
		String[] arrOfChar2 = { "麻", "晴纶","看" };
		String[] arrOfChar3 = { "奎", "康" };
		 String[] arrOfStr = { "lmy", "lyb", "mz", "yx" };

		System.out.println("以下是组合后的数组");


//		Object[][] objectsArrays = assembleArraysToPlanerArray(new Object[][] {arrOfInt, arrOfChar1, arrOfChar2, arrOfChar3,arrOfStr });
		Object[][] objectsArrays = assembleArraysToPlanerArray(new Object[][] { arrOfChar1,arrOfChar2, arrOfChar3 });
//		Object[][] objectsArrays = assembleArraysToPlanerArray(new Object[][] { arrOfChar1,arrOfChar2 });

		int i = 0;
		for (Object[] objArrays : objectsArrays) {
			i++;
			System.out.println(i + "=" + Arrays.toString(objArrays));
		}

	}

	// 方法一的辅助方法:将一个数组类型或对象类型的List与数组组合,并返回List
	@SuppressWarnings("unchecked")
	public static List assembleArrayToList(List aList, Object[] array) {
		List arrList = new ArrayList();
		// 遍历aList,将array与aList进行组合
		for (int i = 0; i 
 <div class="clear">
                 
              
              
        
            </div>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn