Initialize 2D array

前端 未结 5 916
我寻月下人不归
我寻月下人不归 2020-12-02 16:33

I am trying to initialize a 2D array, in which the type of each element is char. So far, I can only initialize this array in the follow way.



        
5条回答
  •  失恋的感觉
    2020-12-02 16:51

    Shorter way is do it as follows:

    private char[][] table = {{'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'}};
    

提交回复
热议问题