Here you can find the source of trimIfLastIndex(List
private static String trimIfLastIndex(List<String> suggestedList, String suggestedWords, int i)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static final String STRING_SPACER = " | "; private static String trimIfLastIndex(List<String> suggestedList, String suggestedWords, int i) { if (isLastIndex(suggestedList, i)) { suggestedWords = trimSuggestions(suggestedWords); }//from w w w .jav a 2s . co m return suggestedWords; } private static boolean isLastIndex(List<String> suggestedList, int i) { return i == suggestedList.size() - 1; } private static String trimSuggestions(String suggestedWords) { int index = suggestedWords.lastIndexOf(STRING_SPACER); return suggestedWords.substring(0, index); } }