添加从文本文件到数组(Java)的Doubledata
我试图弄清楚如何从格式如下的文本文件中读取数据:
1.0,8.0
4.0,3.0
6.0,0.0
3.0,5.0
并在 myNumbers1 中添加每行的第一个元素,在 myNumbers2 中添加第二个元素,如下所示:
double[] myNumbers1 = {};
双[] myNumbers2 = {};
得到
double[] myNumbers1 = {1.0,4.0,6.0,3.0};
double[] myNumbers2 = {8.0,3.0,0.0,5.0};
这有道理吗?谢谢! :)
I am trying to figure out how to read data from a text file formatted as below:
1.0,8.0
4.0,3.0
6.0,0.0
3.0,5.0
and add the first element of each line in myNumbers1 and the second in myNumbers2 like so:
double[] myNumbers1 = {};
double[] myNumbers2 = {};
to get
double[] myNumbers1 = {1.0,4.0,6.0,3.0};
double[] myNumbers2 = {8.0,3.0,0.0,5.0};
if that makes sense? Thanks! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是实现您想要的最简单的方法。
Here is the simplest way to achieve what you want.