Intro to Tutorial Challenges

  • + 2 comments

    I think the comparision could be the condition of the while cycle:

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int search = scan.nextInt();
        scan.nextInt();
        int i = 0;
        while(scan.nextInt() != search){
            i++;
        }
        System.out.println(i);
    }