/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	private static int posOfTarget;
	public static void main (String[] args) throws java.lang.Exception
	{
		int [] arr = {1,2,3,4,5,6};
		int target = 5;
		if(contains(arr,target)){
			System.out.println(target+" found at pos " + getPosOfTarget()+1);
		}
		else
		    System.out.println(target+" doesn't exist in arr ");
	}
	
	public static boolean contains(int[] input, int target) {
    for(int i = 0; i < input.length; i++){
        if (target == input[i]){
        	setPosofTarget(i);
            return true;
        }
    }
    return false;
	}
	
	public static int indexOf(int[] input, int target) {
		if(contains(input, target) == true){
			//pos is already set in contains()
			return (getPosOfTarget());
		}
		else
		    return -1;   
	}
	
	//getter setter of pos
	public static int getPosOfTarget(){
		return posOfTarget;
	};
	public static void setPosofTarget(int i){
		posOfTarget = i;
	};
}