Question Index

Write a program to check the given index valid for given list.

Input String List Given Index Is Valid Index
[One, Two, Three, Four, Five, Six, Seven] 0 true
[Hyderabad, Tirupati, Guntur, Nellore, Ongole] -3 false
{} EMPTY ARRAY 2 false
{} EMPTY ARRAY -1 false
null - NULL ARRAY 3 false
null - NULL ARRAY -1 false

import java.util.*;
class ValidIndexForGivenList
    public static void main(String s[])
        ArrayList<String> list = new ArrayList<String>();
        int index = 1;
        boolean result = isValidIndex(list, index);
        System.out.println("The output string should be "+ result +" if the given index "+index+" is valid for given list "+list);


    public static boolean isValidIndex(List<String> list, int index)
        boolean result = false;
        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