[Solved] Get word pairs from a sentence [closed]


There is a way, lots of ways
one of these can be:

String string = "I want this split up into pairs";
String[] words = string.split(" ");
List<String> pairs = new ArrayList<String>();
for (int i = 0; i < words.length-1; ++i) {
    pairs.add(words[i] + " " + words[i+1]);
}
System.out.println(pairs);

solved Get word pairs from a sentence [closed]