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 ...
随机推荐
- Linux系统中提示/usr/bin/ld: cannot find -lxxx错误的通用解决方法
在linux环境编译应用程式或lib的source code时常常会出现如下的错误讯息: 代码如下: /usr/bin/ld: cannot find -lxxx 这些讯息会随着编译不同类型的sour ...
- Xcode及模拟器SDK下载
http://blog.csdn.net/zhangao0086/article/details/38491271 吐槽下,百度打着无限分享的旗号,却又让分享资源过期,让分享者持续维护 如果你嫌在Ap ...
- angular项目中使用Primeng
1.第一步把依赖添加到项目中 npm install primeng --save npm install @angular/animations --save npm install font-aw ...
- LeetCode301. Remove Invalid Parentheses
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all ...
- 前端代码编辑器ace 语法提示 代码提示
本文主要是介绍ace编辑器的语法提示,自动完成.其实没什么可特别介绍的,有始有终吧,把项目中使用到的ace的功能都介绍下. { enableBasicAutocompletion: false, // ...
- 关于HTML5 boilerplate 的一些笔记
最近在研究HTML5 boilerplate的模版,以此为线索可以有条理地学习一些前端的best practice,好过在W3C的文档汪洋里大海捞针……啊哈哈哈…… 开头的IE探测与no-js类是什么 ...
- pyqt5改变窗体颜色
from PyQt5.QtWidgets import QApplication,QWidget from PyQt5.QtGui import QColor import sys from t im ...
- axios请求数据
1.安装axios模块 import axios from 'axios'; //安装方法 npm install axios //或 bower install axios 2.引入模块 直接引用: ...
- java 可变参数讲解
java5中新增了可变参数,这个可变参数和C语言中的用法是差不多,但实现起来却不一样. 下面我们一起来看看吧. 其实可变参数就是一个数组 class A{ public void func(int.. ...
- 20169211《Linux内核原理与分析》第二周作业
<linux内核分析>实验一实验报告 <linux内核设计与实现>第1.2.18章学习总结 一.<linux内核分析>实验一实验报告 在进行实验楼操作 ...