Question Index

Write a program to get string item before given string item from list.

Input String List Given Input String String Before The Given String
[One, Two, Three, Four, Five, Six, Seven] Six Five
[Ganga, Brahmaputra, Godavari, Krishna] Kaveri null
[spring, summer, monsoon, autumn, winter, winter and fall] null null
{} EMPTY ARRAY Five null
null - NULL ARRAY null null

import java.util.*;
class GetBeforeStringItem
    public static void main(String s[])
        ArrayList<String> list = new ArrayList<String>();
        String inputString = "Six";
        String result = getStringBeforeTheGivenStringFromList(list, inputString);
        System.out.println("The output string should be "+ result +" before the given string "+inputString+" from list "+list);


        public static String getStringBeforeTheGivenStringFromList(List<String> list, String inputString)
            String result = null;
            return result;
        public static Boolean isValidIndex(List<String> list, int index)
            Boolean result = null;
            return result;




Topic: Java ArrayList

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App