import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

public class MoreArrayc {



    public int findIndexOf(int[] arr, int value) {

        int container = 0;


        for (int i = 0; i < arr.length; i++) {

            if (arr[i] == value) {
                container = i;

            }
        }
        return container;
    }

    public Integer[] copyArrayByIteratingthroughIt(Integer [] arr){

        ArrayList<Integer> arr1 = new ArrayList<Integer>(Arrays.asList(arr));
        Iterator<Integer> interate = arr1.iterator();
        Integer [] arr2 = new Integer[arr.length];
        int count = 0;

        while (interate.hasNext()){

            arr2[count] = interate.next();
            count++;

        }

        return arr2;

    }

    public Integer[] copyArrayByLoopingthroughIt(Integer [] arr){


        Integer [] arrCop = new Integer[arr.length];

        for (int i = 0; i <arr.length ; i++) {

            arrCop[i] = arr[i];
        }

        return arrCop;

    }

    public Boolean checkArrayForEquals(Integer[]arr,Integer []arr2){

            Boolean flag = null;



        for (int i = 0; i < arr.length; i++) {

            if(arr[i] == arr2[i]){
                flag = true;
            }else{
                flag = false;
            }
    }
        return flag;
    }

    public Integer[] removeFromArray(Integer [] arr, int value){


        for (int i = 0; i < arr.length; i++) {

            if(arr[i] == value){

                arr[i] = arr[i+1];


            }

        }
        Integer[] cop = Arrays.copyOf(arr,arr.length-1);
        return cop;

    }

    public Integer find2ndLargestValueFromArray(Integer [] arr){

        Integer maxNum;
        Integer secondMax;

       if(arr.length <= 1){
           return arr[0];
       }

       if(arr[0] < arr[1]) {
            maxNum = arr[1];
            secondMax = arr[0];

       }else{
           maxNum = arr[0];
           secondMax = arr[1];
       }

        for (int i = 2; i < arr.length; i++) {

            if(arr[i] > maxNum){

                secondMax =maxNum;
                maxNum = arr[i];

            }else if(arr[i] < maxNum && arr[i] > secondMax){
                secondMax = arr[i];
            }

        }
        return secondMax;
    }
}


//    makeMeAnArrayListFromArray
//    makeMeAnArrayFromArrayList
//    check2ArraysForEqual
//   averageArrayWithoutMaxMin
//    ArrayHas65and77
//    theTotalofTensIs30`
//    makeMeACopyPlease
//    removeLastItemAndCopy
//    removeFirstItemAndCopy
//    insertAtStartAndCopy
//    insertAtEndAndCopy
//    sortArrayIntoEvensThenOdds
