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 ...
随机推荐
- centos7安装lamp
一.准备工作 1. 下载并安装CentOS7.2,配置好网络环境,确保centos能上网,可以获取到yum源. centos7.2的网络配置: vim /etc/sysconfig/network ...
- C语言实现int转换string
#include <stdio.h> #include <stdlib.h> #include <string.h> int string2int(const ch ...
- 当while read line 遇到 ssh
问题:while read line 中使用ssh只能读取一行? #!/bin/sh while read line do echo $line ssh root@$line "echo 1 ...
- 详细介绍Linux finger命令的使用
Linux 允许多个用户使用不同的终端同时登陆,Linux finger命令为系统管理员提供知道某个时候到底有多少用户在使用这台Linux主机的方法,对于这个简单的命令我们还是先介绍一下再举例吧. L ...
- 开源介绍:Google Guava、Google Guice、Joda-Time
一.Guava 是一个 Google 的基于java1.6的类库集合的扩展项目,包括 collections, caching, primitives support, concurrency lib ...
- java版云笔记(二)
云笔记 基本的环境搭建好了,今天做些什么呢,第一是链接数据库(即搭建Spring-Batistas环境),第二是登录预注册. 注:这个项目的sql文件,需求文档,需要的html文件,jar包都可以去下 ...
- 5.rabbitmq 主题
1.生产者 #!/usr/bin/env python import pika import sys connection = pika.BlockingConnection(pika.Connect ...
- 服务器或普通PC裸机安装 ESXI6.5
ESXI :安装包 http://pan.baidu.com/s/1c2gM0Xq (包含注册机和其他套件,驱动打包工具) ESXI 6.5 在服务器安装比较方便,一般intel 的网卡都没多大问题, ...
- 分布式跟踪系统zipkin+mysql
1.初始化数据库: 1) CREATE TABLE IF NOT EXISTS zipkin_spans ( trace_id_high BIGINT NOT NULL DEFAULT 0 COMME ...
- 洛谷P1482 Cantor表(升级版) 题解
题目传送门 此题zha一看非常简单. 再一看特别简单. 最后瞟一眼,还是很简单. 所以在此就唠一下GCD大法吧: int gcd(int x,int y){ if(x<y) return gcd ...