badboy1245
Newbie
I am using c++ and java and i have a return string of ten words and i would like to display a number for each word from the java side. how can i add the number to each word when the string holds ten words?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
String str = "here is some text";
String words[] = str.split(" ");
StringBuilder sb = new StringBuilder();
int i = 0;
for (String word : words) {
sb.append(word).append(String.valueOf(i++));
}
String str = "here is some text";
String words[] = str.split("\n");
StringBuilder sb = new StringBuilder();
int i = 0;
for (String word : words) {
sb.append(word).append(String.valueOf(i++));
}
for (int i=0; i<words.length; i++) {
words[i] = String.valueOf(i+1);
}