src/Recursion/recursion2.java
public static ArrayList<Integer> all_indices(int[] arr, int item, int i, ArrayList<Integer> ans) {

		if (i == arr.length) {
			return ans;
		}

		if (arr[i] == item) {
			ans.add(i);
		}

		return all_indices(arr, item, i + 1, ans);

	}
//	print all the indices of the element appeared 
print all the indices of the element appeared
print all the indices of the element appeared
public static ArrayList<Integer> all_indices(int[] arr, int item, int i, ArrayList<Integer> ans) {
		if (i == arr.length) {
			return ans;
		}
		if (arr[i] == item) {
			ans.add(i);
		}
		return all_indices(arr, item, i + 1, ans);
	}
public static ArrayList < Integer > all_indices ( int [ ] arr , int item , int i , ArrayList < Integer > ans ) { if ( i == arr . length ) { return ans ; } if ( arr [ i ] == item ) { ans . add ( i ) ; } return all_indices ( arr , item , i + 1 , ans ) ; }
print all the indices of the element appeared
print all the indices of the element appeared