StringFormat
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的更多相关文章
- VFP自定义函数StringFormat (仿.NET String.Format 方法)
VFP仿.NET String.Format 方法 将指定字符串中的每个{x}替换为相应值,并返回文本 *-- 调用格式 StringFormat("日期{2},字符{1}",&q ...
- WPF XAML之bing使用StringFormat
WPF XAML之bing使用StringFormat // 转化为百分比 Text="{Binding Progress, StringFormat=\{0:P\}}" < ...
- The StringFormat property
As we saw in the previous chapters, the way to manipulate the output of a binding before is shown is ...
- Silverlight 4常用StringFormat格式总结
原文地址:http://www.silverlightchina.net/html/tips/2011/0424/7149.html 在Silverlight项目中,经常会根据需求的不同,提供不同的字 ...
- WPF在XAML中Binding使用StringFormat属性
1. 绑定Currency, 如果没有字符的话, =后面需要先加入{}. 不加的话会出问题. 1 <TextBlock Text="{Binding Amount, StringFor ...
- StringBuild,StringFormat," "+" " 三种方法速度测试
测试方式: Stopwatch sw = new Stopwatch(); sw.Start(); string tmp = ""; StringBuilder sb = new ...
- 同时使用Binding&StringFormat 显示Text【项目】
Case ID (?unit) 红色的字根据一个后台boolean来做trigger,可以是Case or Open 蓝色的字binding到后台的一个string属性来切换任意的Unit单位 这样一 ...
- wpf Content数据绑定StringFormat起作用的原理和解决(转)
1.简单示例: <Window x:Class="WpfOne.Bind.Bind6" xmlns="http://schemas.microsoft.com/wi ...
- Wpf 数据绑定之BindingBase.StringFormat
BindingBase.StringFormat 属性获取或设置一个字符串,该字符串指定如果绑定值显示为字符串,应如何设置该绑定的格式. StringFormat 可以是预定义的.撰写的或自定义的字符 ...
- WPF XAML之bing使用StringFormat(转)
释义 BindingBase.StringFormat 属性 获取或设置一个字符串,该字符串指定如果绑定值显示为字符串,应如何设置该绑定的格式. 命名空间: System.Windows ...
随机推荐
- java处理金证中登查询图片二进制流问题
package com.szkingdom.kess.model; import java.io.File; import java.io.FileOutputStream; import java. ...
- CSS3 object-fit 图像裁剪
MDN定义 https://developer.mozilla.org/zh-CN/docs/Web/CSS/object-fit 该 object-fit CSS 属性指定替换元素的内容应该如何适应 ...
- Tutorial 4: Authentication & Permissions
转载自:http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/ Tutorial 4: Auth ...
- [ python ] 练习作业 - 3
1. 写出Python查找一个变量的顺序 提示:4中作用域的顺序 本地作用域(local) --> 当前作用域被嵌入的本地作用域(enclsing locals) --> 全局/模块作用域 ...
- Django 注册
一. 本地图片上传预览 1. 上传文件框隐藏到图片上面,点击图片相当于点上传文件框 <div class="login"> <div style="po ...
- 洛谷P1420 最长连号 题解
题目传送门 这道题我是打暴力的...(尴尬) 所以直接是O(N2)的时间,但好像没有炸,数据很水... #include<bits/stdc++.h> using namespace st ...
- 响应式之像素和viewport
引言 按照pc尺寸做好的网页,在手机端打开,看起来像是pc的缩小版,东西都在只是字太小都看不清了,有什么办法放大呢? 于是去google一下,发现,贴了这么一行代码就轻松解决了: <meta n ...
- Maven使用第三方jar文件的两种方法<转>
http://www.cnblogs.com/sekai/p/5932206.html 今天用上了.. ===================== 在Maven中,使用第三方库一般是通过pom.xml ...
- 取消cp确认
使用cp -r -f 强制覆盖拷贝命令时,每一个文件都需要认为的键入“Y”进行确认 可以通过取消同名cp的定义,命令如下unalias cp
- 关于HTML5 boilerplate 的一些笔记
最近在研究HTML5 boilerplate的模版,以此为线索可以有条理地学习一些前端的best practice,好过在W3C的文档汪洋里大海捞针……啊哈哈哈…… 开头的IE探测与no-js类是什么 ...