Java中Scanner.nextLine()的换行问题没有想明白

(JDK17.0)
我用这块代码测试了Scanner的换行问题(第一行输入一个int值,第二行输入一行带空格的String)。

若在IDEA的Run窗口中手动输入,换行需要2次nextLine()吸收,第二行的字符串赋值给了s3;若将数据直接复制输入,换行需要1次nextLine()吸收,第二行字符串赋值给了s2。

为什么逐字输入和直接复制会不一样的呀?


import java.util.Scanner;

public class ScannerTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n1 = sc.nextInt();
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        String s3 = sc.nextLine();


        System.out.println("n1="+n1);

        System.out.println("s1="+s1);
        System.out.println(s1.equals(""));

        System.out.println("s2="+s2);
        System.out.println(s2.equals(""));

        System.out.println("s3="+s3);

    }
}

手动输入

img

复制输入

img

复制的时候是不是多复制了换行符

学java基础就不要用IDEA里边的控制台,用系统原生控制台,IDEA的控制台输入有bug,一直有问题