Reduce repetitive code in Lotto simulator I'm extremely new to Java, and I had a bit of an attempt at making something that you could call lotto. I've still got a lot more to go on it, but things are becoming tedious, and I am sure there is a simpler way to do what I am doing.  How can this code be changed to have less repetitive code/optimized?

import java.util.Random;
import java.util.Scanner;


public class Lotto {

    //Pick 6 numbers from 1 to 100
    //If all of your numbers gets called out, you win

    public static void wait (int n) {
        long t0,t1;
        t0=System.currentTimeMillis();
        do{
            t1=System.currentTimeMillis();
        }
        while (t1-t0&lt;1000);
    }

    public static void main(String[] args) {
        Random rand = new Random();
        Scanner numScan1 = new Scanner(System.in);
        Scanner numScan2 = new Scanner(System.in);
        Scanner numScan3 = new Scanner(System.in);
        Scanner numScan4 = new Scanner(System.in);
        Scanner numScan5 = new Scanner(System.in);
        Scanner numScan6 = new Scanner(System.in);
        boolean num1Cor = false;
        boolean num2Cor = false;
        boolean num3Cor = false;
        boolean num4Cor = false;
        boolean num5Cor = false;
        boolean num6Cor = false;

        System.out.print("Pick 6 numbers from 0 to 25. Pick your first number: ");
        int num1 = numScan1.nextInt();
        System.out.println();
        System.out.print("Pick your second number: ");
        int num2 = numScan2.nextInt();
        System.out.println();
        System.out.print("Pick your third number: ");
        int num3 = numScan3.nextInt();
        System.out.println();
        System.out.print("Pick your fourth number: ");
        int num4 = numScan4.nextInt();
        System.out.println();
        System.out.print("Pick your fifth number: ");
        int num5 = numScan5.nextInt();
        System.out.println();
        System.out.print("Pick your final number: ");
        int num6 = numScan6.nextInt();
        System.out.println("Numbers will now start to be drawn, if all of your numbers are called, you win.");

        while (true) {
            int random = rand.nextInt(25);
            System.out.println("Number " + random + ".");

            if (random == num1) {
                num1Cor = true;
                System.out.println("Your number, " + num1 + ", has been called.");
            }
            else if (random == num2) {
                num2Cor = true;
                System.out.println("Your number, " + num2 + ", has been called.");
            }
            else if (random == num3) {
                num3Cor = true;
                System.out.println("Your number, " + num3 + ", has been called.");
            }
            else if (random == num4) {
                num4Cor = true;
                System.out.println("Your number, " + num4 + ", has been called.");
            }
            else if (random == num5) {
                num5Cor = true;
                System.out.println("Your number, " + num5 + ", has been called.");
            }
            else if (random == num6) {
                num6Cor = true;
                System.out.println("Your number, " + num6 + ", has been called.");
            }


            if (num1Cor == true &amp;&amp; num2Cor == true &amp;&amp; num3Cor == true &amp;&amp; num4Cor == true &amp;&amp; num5Cor == true &amp;&amp; num6Cor == true) {
                System.out.println("You win!!");
                break;
            }

            wait(100);
        }
    }
}
First, you need just one Scanner.

Second, you could store the number choose by the user in an array.

Third, you could iterate the array to find the number there, instead of doing a lot of if and else if.

Forth, the user always wins. This looks like a bug. The while(true) ensures that the numbers are choosen in a way that eventually all the choosen numbers will be drawn. More, nothing stops the user from choosing a number more than once.

Fifth, the wait(100) will fail. You should use Thread.sleep(100) instead. EDIT, oops, I thought you were using Object.wait. It currently works, but Thread.sleep is better.