解释下输出变量的格式
来源:3-8 浮点型案例
keepcoding
2017-10-30 14:53:22
输出变量的格式?输出多个变量代码是怎样的
2回答
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、加号起到连接的作用,谁在前面展示放前面
如果解决了你的疑惑,请采纳,祝学习愉快~~
没有马甲线的安琪拉
2017-10-30
int a=10,b=12; System.out.println(a+","+b);
其实是没明白你想问什么。。。
相似问题