Java keyboard input


Hi! I solve problems in java through intelijidea. I need to enter two numbers from the keyboard, can I somehow enter them myself to check the output? The fact is that when solving the problem, the output is not shown, because there is no data entered from the keyboard, only the result of compilation. Thanks.

public class Solution
{
    public static void main(String[] args) throws Exception
{
    BufferedReader reader = new BufferedReader( new InputStreamReader (System.in));
    String numa = reader.readLine();
    int num1 = Integer.parseInt(numa);
    String numb = reader.readLine();
    int num2 = Integer.parseInt(numb);

    for (int i = 1; i <= num1; num1++)
    {
        for (int j = 1; j <= num2; num2++)
        {
            System.out.print(8);
        }
        System.out.println();
    }
}
} 
Author: Maksim Korkodinov, 2015-11-13

3 answers

Intellij IDEA has a console. There you can write and see the output of the program. Here is a sample code with an image from the IDE:

import java.util.Scanner;

public class test {

    public static void main( String[] args ) {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter some number: ");
        int input = in.nextInt();
        System.out.println("Your input is: " + input);
    }
}

enter a description of the image here

 3
Author: LEQADA, 2015-11-13 19:06:00

Comment out these two sentences

// String numa = reader.readLine();
// String numb = reader.readLine();

And instead, write down the values you want to test. For example

String numa = "10";
String numb = "20";
 2
Author: Vlad from Moscow, 2015-11-13 18:53:53
for (int i = 1; i <= num1; num1++)
    {
        for (int j = 1; j <= num2; num2++)
        {
            System.out.print(8);
        }
        System.out.println();
    }

You have an error when using for, because it turns out to be an infinite loop, where the numbers num1 and num2

 1
Author: HET_APTbI, 2017-07-31 13:20:30