java string api

public static void main(String[] args) {

		String str = new String();
		System.out.println(str);
		System.out.println(str.length());
		System.out.println(str.isEmpty());
		str = "abcde";
		System.out.println(str.charAt(0));
		System.out.println(str.codePointAt(0));// char对应的Unicode编码编号
		System.out.println(str.codePointBefore(2));// 前一个字符串对应编码
		System.out.println(str.codePointCount(0, 2));

		str = "java编程入门";
		byte[] bs = str.getBytes();
		String csn = Charset.defaultCharset().name();// 获取项目默认编码
		System.out.println(csn);
		System.out.println(new String(bs));

		System.out.println("ABC".toLowerCase());
		/**
		 * 转 换 符 说 明 示 例 
		 * 
		 * %s 字符串类型 "mingrisoft" 
		 * %c 字符类型 'm' 
		 * %b 布尔类型 true 
		 * %d 整数类型(十进制) 99 
		 * %x 整数类型(十六进制) FF 
		 * %o 整数类型(八进制) 77 
		 * %f 浮点类型 99.99 
		 * %a 十六进制浮点类型 FF.35AE 
		 * %e 指数类型 9.38e+5 
		 * %g 通用浮点类型(f和e类型中较短的)
		 * %h 散列码
		 * %% 百分比类型 % 
		 * %n 换行符
		 * %tx 日期与时间类型(x代表不同的日期与时间转换符
		 * 
		 */
		for (int i = 0; i < 20; i++) {
			String s = String.format("%02d", i);
			String ss = String.format("a%s", s);
			System.out.println(ss);
		}

	}

你可能感兴趣的:(J2SE)