8.4 Nonrectangular Arrays(非矩形数组)
public class Test {
public static void main(String[] args) {
String[ ] str;
str=new String[2];
str[0]="aaa";
str[1]="bb";
String[ ] str1;
str1=new String[]{"aaa","bbb"};
// 假如写成下一句,就报这个错。Cannot define dimension expressions when an array initializer is provided
// str1=new String[2]{"aaa","bbb"};
System.out.println(str1[0]+str1[1]);
String[][] x = new String[3][];
x[0]=new String[]{"hello","马克-to-win"};
x[1]=new String[]{"are","you","fine"};
x[2]=new String[]{"ok"};
for(int i=0; i<3;i++){
for(int j=0;j<x[i].length;j++){
System.out.println("x["+i+"]["+j+"]"+" is "+x[i][j]);
}
}
}
}
更多请看:https://blog.csdn.net/qq_44639795/article/details/103124325
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有