public class StringFormatDemo {

    public static void main(String[] args) {
String str = null;
str = String.format("Hi,\t %s", "王力");
System.out.println(str);
str = String.format("Hi,\t %s:%s.%s", "王南", "王力", "王张");
System.out.println(str);
System.out.printf("字母a的大写是:\t %c %n", 'A');
System.out.printf("3>7的结果是:\t %b %n", 3 > 7);
System.out.printf("100的一半是:\t %d %n", 100 / 2);
System.out.printf("100的16进制数是:\t %x %n", 100);
System.out.printf("100的8进制数是:\t %o %n", 100);
System.out.printf("50元的书打8.5折扣是:\t %f 元%n", 50 * 0.85);
System.out.printf("上面价格的16进制数是:\t %a %n", 50 * 0.85);
System.out.printf("上面价格的指数表示:\t %e %n", 50 * 0.85);
System.out.printf("上面价格的指数和浮点数结果的长度较短的是:\t %g %n", 50 * 0.85);
System.out.printf("上面的折扣是\t %d%% %n", 85);
System.out.printf("字母A的散列码是:\t %h %n", 'A');
}
}

StringFormat的更多相关文章

  1. VFP自定义函数StringFormat (仿.NET String.Format 方法)

    VFP仿.NET String.Format 方法 将指定字符串中的每个{x}替换为相应值,并返回文本 *-- 调用格式 StringFormat("日期{2},字符{1}",&q ...

  2. WPF XAML之bing使用StringFormat

    WPF XAML之bing使用StringFormat // 转化为百分比 Text="{Binding Progress, StringFormat=\{0:P\}}" < ...

  3. The StringFormat property

    As we saw in the previous chapters, the way to manipulate the output of a binding before is shown is ...

  4. Silverlight 4常用StringFormat格式总结

    原文地址:http://www.silverlightchina.net/html/tips/2011/0424/7149.html 在Silverlight项目中,经常会根据需求的不同,提供不同的字 ...

  5. WPF在XAML中Binding使用StringFormat属性

    1. 绑定Currency, 如果没有字符的话, =后面需要先加入{}. 不加的话会出问题. 1 <TextBlock Text="{Binding Amount, StringFor ...

  6. StringBuild,StringFormat," "+" " 三种方法速度测试

    测试方式: Stopwatch sw = new Stopwatch(); sw.Start(); string tmp = ""; StringBuilder sb = new ...

  7. 同时使用Binding&StringFormat 显示Text【项目】

    Case ID (?unit) 红色的字根据一个后台boolean来做trigger,可以是Case or Open 蓝色的字binding到后台的一个string属性来切换任意的Unit单位 这样一 ...

  8. wpf Content数据绑定StringFormat起作用的原理和解决(转)

    1.简单示例: <Window x:Class="WpfOne.Bind.Bind6" xmlns="http://schemas.microsoft.com/wi ...

  9. Wpf 数据绑定之BindingBase.StringFormat

    BindingBase.StringFormat 属性获取或设置一个字符串,该字符串指定如果绑定值显示为字符串,应如何设置该绑定的格式. StringFormat 可以是预定义的.撰写的或自定义的字符 ...

  10. WPF XAML之bing使用StringFormat(转)

    释义 BindingBase.StringFormat 属性 获取或设置一个字符串,该字符串指定如果绑定值显示为字符串,应如何设置该绑定的格式.        命名空间: System.Windows ...

随机推荐

  1. virsh 命令最新整理。 每个“;”之后是正解

    1,migrate --domain --destURL --dname  --live(热迁移) migrate lf 192.168.16.3 dname 2,managedsave domain ...

  2. C#开发微信公众平台开发-微信海报介绍和开发流程

    “让客户发展客户”,微信海报才是微信公众平台最高明的吸粉手段,海报上有粉丝的专属二维码,有粉丝的头像及商户宣传的广告等.新粉丝扫描这个专属二维码会关注公众号,同时分享海报的粉丝会增加积分换取礼品或者优 ...

  3. 85.Maximal Rectangle---dp

    题目链接:https://leetcode.com/problems/maximal-rectangle/description/ 题目大意:给出一个二维矩阵,计算最大的矩形面积(矩形由1组成).例子 ...

  4. ../include/squid_md5.h:27:2: error: #error Cannot find OpenSSL MD5 headers【squid安装中】

    ../include/squid_md5.h:27:2: error: #error Cannot find OpenSSL MD5 headers yum install -y openssl* w ...

  5. Getting Started with Django Rest Framework and AngularJS

    转载自:http://blog.kevinastone.com/getting-started-with-django-rest-framework-and-angularjs.html A ReST ...

  6. HDU 4725 The Shortest Path in Nya Graph(spfa+虚拟点建图)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4725 题目大意:有n层,n个点分布在这些层上,相邻层的点是可以联通的且距离为c,还有额外给出了m个条边 ...

  7. LeetCode301. Remove Invalid Parentheses

    Remove the minimum number of invalid parentheses in order to make the input string valid. Return all ...

  8. Linux 用户篇——用户管理命令之useradd、passwd、userdel、usermod

    一.用户重要,用户管理命令同样重要 用户是Linux系统安全的核心,每个登录Linux系统的用户都会分配相应的权限,这些权限取决于能否访问系统中各种对象.而管理这些用户的相关信息离不开用户管理命令,比 ...

  9. Linux shell 中$() ` `,${},$[] $(()),[ ] (( )) [[ ]]作用与区别

    转载自 https://blog.csdn.net/x1269778817/article/details/46535729 参考: https://stackoverflow.com/questio ...

  10. ubuntu1604 安装samba

    ubuntu1604 安装samba sudo apt-get install samba 更改/etc/samba/smb.conf添加[share]comment = sharepath = /h ...