解释下输出变量的格式

来源:3-8 浮点型案例

keepcoding

2017-10-30 14:53:22

输出变量的格式?输出多个变量代码是怎样的

写回答

2回答

喜欢做梦的鱼

2017-10-30

1、可以参考以下代码:

int x = 5;        double y = 3.141592;       
        System.out.println("x = " + x + ", y = " + y);  // 一般方式      
        System.out.printf("x = %d, y = %f\n", x, y);  // printf()方式       
        System.out.format("x = %d, y = %f\n", x, y);// format()方式
    }

2、加号起到连接的作用,谁在前面展示放前面

如果解决了你的疑惑,请采纳,祝学习愉快~~

0
heepcoding
h 非常感谢!
h017-10-30
共1条回复

没有马甲线的安琪拉

2017-10-30

int a=10,b=12;
System.out.println(a+","+b);

其实是没明白你想问什么。。。

0
heepcoding
h 还有就是+的位置有什么学问吗,怎么一前一后
h017-10-30
共2条回复

0 学习 · 14452 问题

查看课程