How to initialise a 2D array using CodeModel
问题 I need to initialise a 2d array like below Object[][] someName = { {"param1","param2","param3"}, {"param4","param5","param6"} }; I tried like JExpression exp = JExpr.newArray(codeModel.ref(String.class)).add(JExpr.lit("param1").add(JExpr.lit("param2")); methodBlock.decl(JMod.NONE, codeModel.ref(Object.class).array().array(), dataProviderName, exp); but it initilases 1d array, any help is appreciated 回答1: It might not be exactly the same, but the following code initializes the example 2d array