如何在java中使用两个或多个单个数组声明多维数组变量



是否可以使用许多简单的数组值来声明为多维数组值?

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 };

有两种方法来声明多维数组:

  1. char[][]α= {{A, B, C, D,"E"},{‘F’,‘G’,‘H’,‘我’,' J '}};
  2. char[][] alpha = new char[4][];Alpha [0] = new char[3];[1] = new char[2];

相关内容

  • 没有找到相关文章

最新更新