Menu
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>();
        list.add("One");
        list.add("Two");
        list.add("Three");
        list.add("Four");
        list.add("Five");
        list.add("Six");
        list.add("Seven");
        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;
        }

}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App