gpt4 book ai didi

java - 如何分解Java数组?

转载 作者:行者123 更新时间:2023-12-01 18:32:32 24 4
gpt4 key购买 nike

我正在编写一个处理信号数组的java程序。

该数组是通过将 midi 文件转换为 midi-text 文件得到的:

Signal [] sig= {"a1a2a3", "b1b2b3", "c1c2c3", "d1d2d3"};



Signal [] sig1 = {"a1", "b1", "c1", "d1"};
Signal [] sig2 = {"a2", "b2", "c2", "d2"};
Signal [] sig3 = {"a3", "b3", "c3", "d3"};

如何实现?

最佳答案

你了解MultiMap吗?

I think you can implement multimap while creating original array.

浏览:http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/Multimap.html

简单的解决方案如下:

如果一个数组是这样的

Signal [] sig= {a1a2a3, b1b2b3, c1c2c3, d1d2d3};
for(int i = 0;i<sig.size();i++){
for(int j = 0;j<sig[i].length() ;j++){
newArray.add(sig.subString(j,j+1));
}
}

你可以通过这样的字符串操作来完成。可以吗?

关于java - 如何分解Java数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23509082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com