1 of 3

Beginner Java Question. Infinite loop?

Writing a program for my intro to comp sci course where I'm supposed to prompt the user to enter a stream of integers, and then return the largest two. We were given the hint to use a scanner and a while loop with the condition .hasnext.

I'm not sure why this program isn't working properly but I suspect the loop is running infinitely. Any advice on what I should do? Also, I apologize with the poor formatting of this post. This is my first time asking a question here.

package Homework;

import java.util.*;

public class Question1 {

public static void main(String[] args) {
    System.out.println("Please type your integers");
    Scanner kbd = new Scanner(System.in);
    int big = 0;
    int big2 = 0;

    { //Opens while loop
        int num = kbd.nextInt();
        if(num > big) { // opens If statement
            big2 = big;
            big = num;
            } //Closes If statement
        else if((num < big) && (num > big2))  {
            big2 = num;
        } //closes else if statement            
    } //Closes while loop 
} //Closes method