有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在一些输入已经完成后将输入字符串作为句子

样本输入: 12, 4.0, 非常适合存储数据

预期产出: 16, 8.0, 字符串很适合存储数据

实际产量: 16, 8.0, 串

public static void main(String[] args) {

        int i = 4;
        double d = 4.0;
        String s = "string ";

        Scanner scan = new Scanner(System.in);

        int i1;
        double d1;
        String s1;
        i1 = scan.nextInt();
        d1 = scan.nextDouble();
        s1 = scan.nextLine(); // if i am add this line before taking i1 is than its working fine but here not?

        System.out.println(i + i1);
        System.out.println(d + d1);
        System.out.println(s + " " + s1);
        scan.close();
    }

共 (0) 个答案