System.out.printf() 的用法

package com.wind;

/**
 * @author Wind
 */
public class TestPrintf {
    public static void main(String[] args) {
        //定义一些变量,用来格式化输出。
        double d = 345.678;
        String s = "你好!";
        int i = 1234;
        //"%"表示进行格式化输出,"%"之后的内容为格式的定义。
        System.out.printf("%f", d);//"f"表示格式化输出浮点数。
        System.out.println();
        System.out.printf("%9.2f", d);//"9.2"中的9表示输出的长度,2表示小数点后的位数。
        System.out.println();
        System.out.printf("%+9.2f", d);//"+"表示输出的数带正负号。
        System.out.println();
        System.out.printf("%-9.4f", d);//"-"表示输出的数左对齐(默认为右对齐)。
        System.out.println();
        System.out.printf("%+-9.3f", d);//"+-"表示输出的数带正负号且左对齐。
        System.out.println();
        System.out.printf("%d", i);//"d"表示输出十进制整数。
        System.out.println();
        System.out.printf("%o", i);//"o"表示输出八进制整数。
        System.out.println();
        System.out.printf("%x", i);//"d"表示输出十六进制整数。
        System.out.println();
        System.out.printf("%#x", i);//"d"表示输出带有十六进制标志的整数。
        System.out.println();
        System.out.printf("%s", s);//"d"表示输出字符串。
        System.out.println();
        System.out.printf("输出一个浮点数:%f,一个整数:%d,一个字符串:%s", d, i, s);
        //可以输出多个变量,注意顺序。
        System.out.println();
        System.out.printf("字符串:%2$s,%1$d的十六进制数:%1$#x", i, s);
        //"X$"表示第几个变量。
    }
}
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
全志R16平台编译linux系统V1.0.txt 2017/4/11 13:36 (编译请使用编译android的lichee的选项编译生成的.config文件,不然直接编译会报错!!!!) rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ tar zxvf lichee_parrotv1.1_20161202.tar.gz rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ cd lichee/ rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ ./build.sh config Welcome to mkscript setup progress All available chips: 0. sun8iw5p1 Choice: 0 All available platforms: 0. android 1. dragonboard 2. linux 3. tina Choice: 2 All available kernel: 0. linux-3.4 Choice: 0 All available boards: 0. bell-one 1. evb 2. evb-20 3. evb-30 4. evb-rtl8723bs 5. sc3813r Choice: 3 rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ ./build.sh 错误1: KCONFIG_AUTOCONFIG=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/tristate.config BUILDROOT_CONFIG=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/.config /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/conf --silentoldconfig Config.in # # make dependencies written to .auto.deps # ATTENTION buildroot devels! # See top of this file before playing with this auto-preprequisites! # make[1]:正在离开目录 `/home/wwt/linux_r16/lichee/buildroot' You must install 'makeinfo' on your build machine makeinfo is usually part of the texinfo package in your distribution make: *** [dependencies] 错误 1 make:离开目录“/home/wwt/linux_r16/lichee/buildroot” ERROR: build buildroot Failed rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ d/buildroot-config/conf.o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/zconf.tab.o -o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buil

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Windyº

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值