This question already has an answer here:
这个问题在这里已有答案:
- How to split a string in Java 31 answers
如何在Java 31答案中拆分字符串
String word = "Place AA BC CD EF AB";
Say I have a simple string word declared like that. Now I want to ignore the first word and go through the string contents excluding the first word. How would this be possible. Could I split at the first whitespace or is there some other way. Any help will be appreciated. Say there's an array called String [] list. This String word is list[i]. How would I split that to ignore the first word within that.
假设我有一个简单的字符串单词。现在我想忽略第一个单词并浏览除第一个单词之外的字符串内容。怎么会这样呢?我可以在第一个空格分开,还是有其他方式。任何帮助将不胜感激。假设有一个名为String [] list的数组。这个String字是list [i]。如何将其拆分以忽略其中的第一个单词。
2 个解决方案
#1
1
Just split it and then remove from array content on index 0. This should remove the first splitted word in given string.
只需将其拆分,然后从索引0上的数组内容中删除。这应该删除给定字符串中的第一个拆分字。
#2
0
String word = "Place AA BC CD EF AB";
word = word.substring(word.indexOf(" ")+1); //choose +1 for the next index
#1
1
Just split it and then remove from array content on index 0. This should remove the first splitted word in given string.
只需将其拆分,然后从索引0上的数组内容中删除。这应该删除给定字符串中的第一个拆分字。
#2
0
String word = "Place AA BC CD EF AB";
word = word.substring(word.indexOf(" ")+1); //choose +1 for the next index