在输入一些输入之后如何将输入字符串作为句子

时间:2017-06-07 06:38:03

标签: java string types java.util.scanner

示例输入:     12,     4.0,     适合存储数据!

预期OutPut:     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 个答案:

没有答案