作者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/m.aspx?n=bbs/java/M.1580824521.A.A81.html