Java tutorial
//package com.java2s; import java.util.List; public class Main { /** * @param string - this is the current value, e.g. itemNo * @param list - list of strings, e.g. list of products * @return string value * method = getNextInList * Send in value and a list of values, returns the next value from the list. * returns null if the value sent in is the last value in the list. * */ public static String getNextInList(String string, List list) { String nextString = null; if (list != null) { int i = list.indexOf(string); if (list == null || i == list.size() - 1 || list.size() < 2) {//this is the last item/value in the list System.out.println("this is the last item/value in the list"); return nextString; } else { nextString = list.get(i + 1).toString(); System.out.println("what is next item/value= " + nextString); } } return nextString; } }