作者qrtt1 (有些事,有时候。。。)
看板java
标题Re: [问题] 请问JAVA有二维字串这种东西吗?
时间Tue Feb 4 21:55:19 2020
※ 引述《SST2000 (BMW 428i)》之铭言:
: String []str = {"abc","bca","cab","cba","aaa","111","232","112","ABC"}; 字串阵
: 列宣告方式
: 请问有二维自串这种东西吗??
比 1 维再多 1 个维度,不就是 2 维了吗?
public class Foo {
public static void main(String[] args) {
String[][] strings = {{"A", "B", "C"}, {"D", "E", "F"}};
for (int i = 0; i < strings.length; i++) {
for (int j = 0; j < strings[i].length; j++) {
System.out.printf("%s ", strings[i][j]);
}
System.out.println();
}
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 36.231.132.4 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/java/M.1580824521.A.A81.html