从 ArrayList 中检索数据
我有这个变量:
protected ArrayList<String> list = new ArrayList<String>();
数据采用这种形式:
data = date + ": " + y + "L/100KM "+ " " + value1 + "dt "+ value2 + "KM\n";
我想从中检索数据value1
。我该怎么做?
I have this variable:
protected ArrayList<String> list = new ArrayList<String>();
The data is in this form:
data = date + ": " + y + "L/100KM "+ " " + value1 + "dt "+ value2 + "KM\n";
I want to retrieve a data value1
from it. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以像这样在空格上分割:
你的 value1 应该是这个数组中的第三项,所以你可以通过调用来访问它:
或者如果你写了这段代码,为什么你会尝试从你刚刚放置的字符串中获取值珍视自己。 :)
you can just split on whitespace like this:
your value1 should be third item in this array, so you can access it by calling:
Or if you wrote this code why the hell would you try to get value from a string where you just put that value yourself. :)
您将必须使用正则表达式。
You will have to use regular expressions.