是否可以使用许多简单的数组值来声明为多维数组值?
char[] alpha1 = {"A","B","C","D","E"};
char[] alpha2 = {"F","G","H","I","J"};
//Is it possible? Give me a solution for this situation:
char[][] alpha = { alpha1[] , alpha2[] };
对于" "
,您声明一个String。使用' '
作为字符
但是,是的,这是可能的,但你必须删除[]
:
char[] alpha1 = {'A','B','C','D','E'};
char[] alpha2 = {'F','G','H','I','J'};
char[][] alpha = { alpha1 , alpha2 };
有两种方法来声明多维数组:
- char[][]α= {{A, B, C, D,"E"},{‘F’,‘G’,‘H’,‘我’,' J '}};
- char[][] alpha = new char[4][];Alpha [0] = new char[3];[1] = new char[2];